idToken getting set as empty string & provider is not available

We recently migrated to the no modal SDK and are using custom JWT verifier along with google, facebook social logins. After the user logs in (ux mode: redirect), the idToken is getting set as "" in the local storage which is blocking our flow to add the web 3 account to backend. And after 2 or 3 logins this might get fixed.

We are facing some similar issue with provider as well, the provider is not available after some users logs in but may become available in the next try. We encountered both issues when the user opting for custom jwt verifier flow.

Also both the issue are not persistent, but is happening intermittently for some users

  • SDK Version:
"@web3auth/base": "^5.1.0",
    "@web3auth/no-modal": "^5.1.0",
    "@web3auth/openlogin-adapter": "^5.1.1",

web3auth code snippet:

 useEffect(() => {
    const init = async () => {
      try {
        setIsLoading(true)

        const currentChainConfig = CHAIN_CONFIG[currentNetwork]

        const web3AuthInstance = new Web3AuthNoModal({
          clientId: config.web3AuthKey,
          web3AuthNetwork: config.web3AuthNetwork,
          chainConfig: {
            chainNamespace: currentChainConfig.chainNamespace,
            chainId: currentChainConfig.chainId,
            rpcTarget: currentChainConfig.rpcTarget,
          },
        })

        const { OpenloginAdapter } = await import('@web3auth/openlogin-adapter')
        const adapter = new OpenloginAdapter({
          adapterSettings: {
            uxMode: 'redirect',
            redirectUrl: `${baseURL}/signin`,
            replaceUrlOnRedirect: false,
            whiteLabel: {
              name: 'Platform name',
              logoLight: 'image-url',
              logoDark: 'image-url',
              defaultLanguage: 'en',
              // dark: true,
            },
            loginConfig: {
              google: {
                name: 'Verifier name,
                verifier: 'verifier',
                typeOfLogin: 'google',
                clientId: config.web3AuthGoogleClientId,
              },
              facebook: {
                 name: 'Verifier name,
                verifier: 'verifier',
                typeOfLogin: 'facebook',
                clientId: config.web3AuthFacebookClientId,
              },
              twitter: {
                name: 'Verifier name,
                verifier: 'verifier',
                typeOfLogin: 'twitter',
                clientId: config.web3AuthJwtClientId,
              },
              jwt: {
                name: 'Verifier name,
                verifier: 'verifier',
                typeOfLogin: 'jwt',
                clientId: 'client-id',
              },
            },
          },
        })

        web3AuthInstance.configureAdapter(adapter)
        setWeb3Auth(web3AuthInstance)
        await web3AuthInstance.init()
        setProvider(web3AuthInstance.provider)
      } catch (error) {
        console.error(error)
      } finally {
        setIsLoading(false)
      }
    }
    init()
  }, [])

I have removed the verifier names & some information which are related to our platform. But this is basically the whole web3auth setup which is almost similar to what’s there in the integration builder.

Found something like this when we turned on the error log. This happened when we tried to fetch the user info & again in this case the idToken was an empty string in localStorage

Hey @vishnu.rk

Can you share the name of the verifiers and the web3auth network?

Also, as you said, the issue is not persistent. Would you be able to tell what % is failing?

Does this error appear on an incognito window or a new browser as well?

root-jwt-verifier. cyan mainnet

idToken getting set as “” was rare compared to other. This must have happened like 3-4 times out of 30 rounds of testing.

The provider was not getting set for a long time and most of our users faced this issue.

This has happened on normal browser window as well as incognito

Thanks for sharing.

To better understand the error and resolve it, we would need to know the specific error message(s) that appeared in the browser console. In the meantime, we will investigate internally to determine if other clients have reported similar issues.

Okay, can you clear the localStorage and sessionStorage from your browser’s application tab and try again?

There wasn’t any error getting logged to the console. I’ve already tried clearing localStorage multiple times. If you can share your email id, I’ll send more screenshots which has the session related information.(For idToken issue)

The provider issue was recurring in nature and this was happening only on the cyan mainnet and not on testnet. Can you please check with the team what are the chances of provider not getting set after successful login redirection?

Thanks

I tried the signin flow using custom jwt verifier for a new user. After successful redirection the user got redirected to our website. But this error is getting logged, when we are trying to fetch the wallet address and user info.

@vishnu.rk were you able to resolve the issue?

I am also experiencing the idToken to be an empty string all of a sudden. Unsure of the causes here.

unfortunately no @wahid

Hey @wahid

Could you share your init and login code snippets here?

Hey @vishnu.rk

Looking at the code here, I see a typo. ' is missing at the end of the name under different loginConfig. And to be sure here, idToken is blank in all and not just the jwt login provider?

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