Getting error when try to do custom authentication

I am trying to implement custom authentication for telegram users using web3auth. I am following this guide https://web3auth.io/docs/auth-provider-setup/byo-jwt-providers. I created everything but I am getting below error when trying to login the user

{
  "errorMsg": "Could not get result from torus nodes \n Error occurred while verifying params json: cannot unmarshal number into Go value of type string",
  "errorStack": "Error: Could not get result from torus nodes \n Error occurred while verifying params json: cannot unmarshal number into Go value of type string\n    at et (https://auth.web3auth.io/v5/assets/index-b8960750.js:1:1494)\n    at https://auth.web3auth.io/v5/assets/index-b8960750.js:1:9553",
  "title": "Mount Error",
}

Below is my react code

useEffect(() => {
    const init = async () => {
      try {
        const chainConfig = {
          chainNamespace: CHAIN_NAMESPACES.EIP155,
          chainId: '0x1',
          rpcTarget: 'https://rpc.ankr.com/eth',
          displayName: 'Ethereum Mainnet',
          blockExplorer: 'https://etherscan.io',
          ticker: 'ETH',
          tickerName: 'Ethereum',
        };
        const web3auth = new Web3AuthNoModal({
          clientId: clientId,
          chainConfig,
          web3AuthNetwork: OPENLOGIN_NETWORK.SAPPHIRE_DEVNET,
          useCoreKitKey: false,
        });

        const privateKeyProvider = new EthereumPrivateKeyProvider({ config: { chainConfig } });

        const openloginAdapter = new OpenloginAdapter({
          adapterSettings: {
            uxMode: 'redirect', // redirect or popup
            whiteLabel: {
              appName: 'Test',
              appUrl: 'https://web3auth.io',
              defaultLanguage: 'en',
              mode: 'light',
              theme: {
                primary: 'blue',
              },
              useLogoLoader: true,
            },
            loginConfig: {
              jwt: {
                verifier: 'telegram-bot-3',
                typeOfLogin: 'jwt',
                clientId: clientId,
              },
            },
          },
          privateKeyProvider,
        });

        web3auth.configureAdapter(openloginAdapter);
        setWeb3auth(web3auth);
        await web3auth.init();

      } catch (error) {
        console.error(error);
      }
    };

    init();

    const urlToken = getTokenFromUrl();
    if (urlToken) {
      setToken(urlToken);
    }
  }, []);

await web3auth.connectTo(WALLET_ADAPTERS.OPENLOGIN, {
      loginProvider: 'jwt',
      extraLoginOptions: {
        id_token: token,
        verifierIdField: 'sub',
      },
    });

here is how I am generating the token:

const now = Math.floor(Date.now() / 1000);
  const token = jwt.sign(
    {
      sub: userId,
      email: userEmail,
      aud: 'urn:my-resource-server',
      iss: 'https://payments.sandbox.zoksh.com',
      iat: now - 30,
      exp: now + 60 * 60, // Token valid for 1 hour
    },
    PRIVATE_PEM_KEY,
    { algorithm: 'RS256', keyid: KEY_ID }
  );

How to solve the error? Is there anything which I am missing?

@dayanidhee.singh Welcome Aboard!

Your issue has been forwarded to our Dev team and we will get back with further updates.

hey @dayanidhee.singh, can you please share a screenshot of the dashboard where you have configured this custom verifier? Specifically, I wish to confirm the validation field and validation id sections.

@maharshi Here is the screenshot of my custom verifier.


Instead of “email_verified”, please add aud and iss as validation with values as urn:my-resource-server and https://payments.sandbox.zoksh.com as their values respectively. Please don’t forget to remove the email_verified validation.

Hi @maharshi
I changed the validations values but still getting the same error

{
  "errorMsg": "Could not get result from torus nodes \n Error occurred while verifying params json: cannot unmarshal number into Go value of type string",
  "errorStack": "Error: Could not get result from torus nodes \n Error occurred while verifying params json: cannot unmarshal number into Go value of type string\n    at et (https://auth.web3auth.io/v5/assets/index-b8960750.js:1:1494)\n    at https://auth.web3auth.io/v5/assets/index-b8960750.js:1:9553",
  "title": "Mount Error",
  "createdAt": "07/11/2023, 10:53:48",}

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.