[SOLVED] During Morallis Authentication getting error: Moralis auth failed, invalid data

I am using Morallis self hosted server. Previously authentication process was working fine. But from today I am getting:
error: ‘Moralis auth failed, invalid data Error’
status: 404
for API: /server/users
I am using authentication code as per the documentation.
Code:
setLoading(true)
if(!Boolean(window.ethereum && window.ethereum.isMetaMask)){
throw setError(“Please install metamask.”)
}

        await enableWeb3({ throwOnError: true, provider:'metamask' });

          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');
        }
        const { message } = await Moralis.Cloud.run('requestMessage', {

          address: account,

          chain: chainId===parseInt(chainId, 16), 

          networkType: 'evm',

        });


         let _user =  await authenticate({
          signingMessage: message,
          throwOnError: true,
         })

        }

Metamask pop-up screenshot:


Here we can see that expiration time is less than issue time.

1 Like

Hi @dev5, Please check this post.
This is happening due to a hardcoded expiration in parse server backend.

You can update the EXPIRATION_TIME const value under parse-server-migration/src/auth/authService.ts file and restart the server.

3 Likes

Issue is resolved now.Thank you.

3 Likes