idToken consistently empty with 2 providers

I am trying to use web3auth to get the idToken but it is comping up empty. I have tried with the the passwordless email and Google providers and both have the same issue. I am testing on testnet.

Only upside I see is that the error is consistent, which differs from what I’ve found in the forums.

What could be wrong?

      const chainConfig = {
        chainNamespace: CHAIN_NAMESPACES.EIP155,
        displayName: "Polygon",
        ticker: "MATIC",
        tickerName: "Polygon",

        // Testnet
        chainId: "0x13881",
        rpcTarget: "https://rpc.ankr.com/polygon_mumbai",
      };

      const web3auth = new Web3AuthNoModal({
        clientId,
        web3AuthNetwork: "testnet",
        chainConfig,
      });

      const privateKeyProvider = new EthereumPrivateKeyProvider({
        config: { chainConfig } as unknown as EthereumPrivKeyProviderConfig,
      });

      // Configure how we want web3auth to handle MFA and other settings it allows
      const openloginAdapter = new OpenloginAdapter({
        adapterSettings: {
          network: "testnet",
        },
        privateKeyProvider,
      });

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

    const web3authProvider = await web3auth.connectTo(WALLET_ADAPTERS.OPENLOGIN, {
      loginProvider: "email_passwordless",
      extraLoginOptions: {
        login_hint: "john@doe.com",
      },
    });

I’ve noticed that if I used my testnet client id with the cyan network, it works correctly locally. It does not work in our live domain with this set up.

I also tried using the cyan client id with the cyan network in our live domain and it does the same thing, idToken comes up empty.

@miguel Thanks for reaching out.

Your issue has been fowarded to our team and we will get back with further updates once more information becomes available.

Hey @miguel,
We have an example already on email-passwordless but that uses auth0. I’ll link it here for your convenience. But if this doesn’t work for you, let me know the verifier you are using and the code snippet you are using to console.log the idToken.

Hey, i have the same problem. Is there any updates?

My reply missed the link last time. Please re-recheck the reply above.

Hey @maharshi

Thanks for getting back to me.

I am not using custom authentication though, my understanding is that I don’t need a verifier in that case?

For example, this is how I do Google authentication:

    const web3authProvider = await web3auth.connectTo(WALLET_ADAPTERS.OPENLOGIN, {
      loginProvider: "google",
    });

This is the code we use to obtain the idToken:

    const tokens = await web3auth?.authenticateUser();

    const idToken = tokens?.idToken;

Using either the password less email that I sent earlier and Google, both do not return the JWT token.

2 Likes

Is there any update to this?

I have not been able to resolve this issue.

Thank you!

Hey @miguel, I tried using your code snippet and I noticed that the blockExplorer parameter is missing in the chainConfig. I tried the email passwordless flow on on our example using the same SDK you’re using, i.e. Web3AuthNoModal. It is providing the idToken.
I am leaving the link here, I understand you’re using it in a React app. Try out the email passwordless flow. I am able to get the idToken.

Not sure if it was the blockExplorer added or something else, but it is working now.

Thank you!

1 Like