[solved] Parse server migration returns "Error: unauthorized"

Hi,

I set up the parse server following the tutorial trying to run it locally

My code worked perfectly with the Moralis Server Free tier and now I get the following errors:

The runContractFunction is returning ā€œunauthorizedā€ and also the method to get all the getNFTs returns unauthorized. Am I doing something wrong, is there a place to specify the authorization rules?

I am using Moralis from my react app.

Best regards,

You usually have to use latest version of Moralis v1 sdk or to change the server code to automatically set the app id for cloud code functions.

When you say the latest version of Moralis v1 sdk do you mean for the frontend? I am not using any cloud code functions, only smart contract native functions.

I am currently using for the frontend:

    "moralis": "^1.5.9",
    "react-moralis": "^1.3.5",

And the backend parse server:

    "@moralisweb3/common-core": "^2.10.0",
    "@moralisweb3/parse-server": "2.10.0",
    "moralis": "^2.10.0",

Do you know if there is something incompatible here?

I mean for the front end to use latest version of moralis v1 sdk

you can look in network tab to see if the app id is sent with that request when you try to make a cloud function call from front end, if it isnā€™t present there then it has to be added somehow

Hi @cryptokid,

Migrating to:
ā€œmoralisā€: ā€œ^1.11.0ā€,

solved the issue for the frontend. Nevertheless when I do the another Moralis call such as the following from my node.js backend I get the unauthorized error, I also upgraded the moralis dependency to the same version.

    const tokenIdMetadata: any = await Moralis.Web3API.token.getTokenIdMetadata(
      options
    )

this is the latest version? I thought that 1.12.0 is the latest version

in backend you can try to delete all the node_modules folder and try again from 0

did you use Moralis.start in backend with the correct appId?

there is also the option to set automatically the appId for all cloud function

in backend you can also use moralis sdk v2 if you want that requires only an api key

I tried npm install [email protected] and it doesnā€™t work I checked on the npm website it is not listed.

I did use Moralis.start with the correct appId. Deleting node_modules didnā€™t help

I checked the HTTP request sent from the backend and it doesnā€™t contain the appId, is there a way to force passing it?

Otherwise Iā€™ll try the v2 as you suggested.

there is a way to set the app id directly for any cloud function in backend by adding few lines to current cloud code, there is an example in another forum thread on how to do it

Deleted the previous post because it seems that I misread the error it may work!

Adding _ApplicationId to the options seems to work.

1 Like

How did you add that app id?