Problem with login for new users on the site, method authenticateUser returns empty idToken

Please provide the following details too when asking for help in this category:

Hello colleagues!
We have a site, base version: web3wed.io, and they both have web3auth installed, which is currently not working - login fails. A window opens, you can enter data, but then it says “you are connected”, but the page does not change and attempts to log in again give errors. The problems started the day before yesterday when you had migration matters.

Behavior video: Wedd_web3auth.wmv - Google Drive

We have attached our code below, method authenticateUser returns empty idToken.
Maybe we need to change something?

  • SDK Version: “@web3auth/base”: “^5.0.1”,
    @web3auth/core”: “^4.6.0”,
    @web3auth/openlogin-adapter”: “^5.0.1”,

  • Platform: hereinbefore

  • Browser Console Screenshots:

  • Related to Custom Authentication? Please provide the following info too: (Optional)

    • Verifier Name:
    • JWKS Endpoint:
    • Sample idToken(JWT)

Please provide the Web3Auth initialization and login code snippet below:
const login = async (adapter: WALLET_ADAPTER_TYPE, loginProvider: LOGIN_PROVIDER_TYPE, login_hint?: string) => {
try {
setIsLoading(true);
if (!web3Auth) {
console.log(‘web3auth not initialized yet’);
return;
}
const localProvider = await web3Auth.connectTo(adapter, {
loginProvider,
login_hint,
mfaLevel: ‘none’,
sessionTime: SESSION_TIME,
extraLoginOptions: {
max_age: SESSION_TIME,
},
});
await updateNetwork(localProvider);
if (window.screen.width > 600) {
toast.success(‘Successfully signed in’);
}

  await getUserInfo(); // ERROR IS HERE
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
  toast.error('Something went wrong, reload the page');
  toast.error(error);
  console.log('login web3auth', error);
} finally {
  setIsLoading(false);
}

};

///////////////

const getUserInfo = useCallback(
async (web3AuthInstance?: Web3AuthCore) => {
  if (!web3AuthInstance && !web3Auth) {
    console.log('web3auth not initialized yet');
    return;
  }
  const instance = web3Auth || web3AuthInstance;

  try {
    const { idToken } = await instance!.authenticateUser(); // idToken is empty
    const tokenExpirationTime = getTokenExpirationTime(idToken || '');
    const tokenMaxAge = ((tokenExpirationTime * 1000 - Date.now()) / 1000).toFixed(0);
    Cookies.set('token', idToken || '', { expires: +tokenMaxAge });
    localStorage.setItem('token', idToken || '');
    const userInfoFromBackend = await userApi.getUser();

    updateUser({ ...userInfoFromBackend });
    dispatch(coupleActions.getCouple());

    // eslint-disable-next-line @typescript-eslint/no-explicit-any
  } catch (error: any) {
    console.log('GET USER ERROR', error);
    Cookies.remove('token');
    dispatch(userActions.clearUserState());
  }
},
[dispatch, updateUser],

);

1 Like

Getting a similar issue too. The verifications emails are only being sent after the verification links expire.

1 Like

Same problem. idToken is undefined

Same problem, return empty idToken. What happen ?

Same problem. We’re getting empty idToken very frequently and it’s breaking the experience for many of our users. This is a critical bug.

1 Like

This issue has already been forwarded to our team to look into on priority and we will get back with an update on Monday.

Any update on this issue?

Sorry for the delay.

Our team updated that this is fixed in the latest version in Web3Auth Version 6.1.7.

I am using the latest version but the first login has no idToken

@here I have tested with our react-evm-no-modal example. The authenticateUser() methods returns valid idToken.

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