[Archive] Cannot get idToken when calling authenticatedUser() from MetaMask adapter using NoModal SDK

:classical_building: Archived Content from Web3Auth Community

This topic was originally posted by afarley on 3/5/2024.
This content has been migrated from our previous community forum to preserve valuable discussions.


  • SDK Version: v8
  • Platform: No Modal SDK

Using NoModal SDK and MetaMask, calling authenticatedUser() results in a 400 response from https://authjs.web3auth.io/siww/verify:

{
"statusCode":400,
"error":"Bad Request",
"message":"Validation failed",
"validation": {"body":{"source":"body","keys":["timeout"],"message":"\"timeout\" must be greater than or equal to 86400"}}
}

Web3Auth Instance Code:

export const getWeb3AuthInstance = (chains: readonly Chain[]) => {
  const chainConfig = {
    chainNamespace: CHAIN_NAMESPACES.EIP155,
    chainId: '0x' + chains[0].id.toString(16),
    rpcTarget: chains[0].rpcUrls.default.http[0],
    displayName: chains[0].name,
    tickerName: chains[0].nativeCurrency?.name,
    ticker: chains[0].nativeCurrency?.symbol,
    blockExplorerUrl: chains[0].blockExplorers?.default.url[0] as string,
  };

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

const web3AuthInstance = new Web3AuthNoModal({
clientId: environment.web3AuthClientId,
web3AuthNetwork: OPENLOGIN_NETWORK.TESTNET,
storageKey: ‘local’,
chainConfig,
enableLogging: false,
sessionTime: 3600, // 1 hour in seconds,
privateKeyProvider,
});

web3AuthInstance.configureAdapter(
new OpenloginAdapter({
adapterSettings: {
uxMode: ‘redirect’,
replaceUrlOnRedirect: false,
},
loginSettings: {
mfaLevel: ‘none’, // Testnet
},
}),
);

web3AuthInstance.configureAdapter(new MetamaskAdapter());

return web3AuthInstance;
};

const {idToken} = await web3Auth!.authenticateUser();

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

Hi @afarley,

I have just tested the no-modal example with Metamask and is working ok.

Please check the example with Metamask Adapter: https://github.com/Web3Auth/web3auth-pnp-examples/tree/main/web-no-modal-sdk/blockchain-connection-examples/evm-no-modal-example