Invalid Session Token Error During getAllERC20 Call

Hi Moralis team,
We are trying to get all ERC20 tokens owned by the user right after the login:

async function login() {
        let user = Moralis.User.current();
        if (!user) {
          user = await Moralis.Web3.authenticate();
        }
const balances = await Moralis.Web3.getAllERC20();
console.log(balances); 
      }

POST 400 Error
https://{our_server_url}/server/functions/getAllERC20

Body:
{"code":209,"error":"Invalid session token"}

Please let us know if one of the functions is creating the collision in these requests.
Thank you in advance!

Hi,

Please check out this answer where another developer also faced a similar issue –

Let me know if this helps.

Have a nice day. :slight_smile:

Thank you, Malik, but this exactly the same code we are using. Maybe there is another issue. Can Moralis SDK be used by js code only, is there a server set-up required for the getAllErc20 call?

Hi,
I had the same ‘POST 400’ error and I fixed it by creating another server connected to ‘Mainnet’ - where the tokens were located - instead of ‘Ganache’.
Hope this helps.