i want to authenticate web3auth using react moralis but it’s not working
here is my code
const handleAuth = async (provider: ‘metamask’ | ‘walletconnect’ | ‘magicLink’ | ‘web3Auth’ = ‘metamask’) => {
try {
setAuthError(null);
setIsAuthenticating(true);
// Enable web3 to get user address and chain
await enableWeb3({ throwOnError: true, provider });
const { account, chainId } = Moralis;
if (!account) {
throw new Error('Connecting to chain failed, as no connected account was found');
}
if (!chainId) {
throw new Error('Connecting to chain failed, as no connected chain was found');
}
// Get message to sign from the auth api
const { message } = await Moralis.Cloud.run('requestMessage', {
address: account,
chain: parseInt(chainId, 16),
networkType: 'evm',
});
// Authenticate and login via parse
await authenticate({
signingMessage: message,
throwOnError: true,
clientId: "BCl7lfrORJxp_fBvPA08AF3_w4th0uHpKBLMB9t1uA8Inba3SP1xpQ1uGO18Q4RnQRgCzVo9u11M2qPpMOZ5Z5Q",
});
onClose();
} catch (error) {
setAuthError(error);
} finally {
setIsAuthenticating(false);
}
};