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],
);