Forge requestgraph() error in authorization

hi,

I am trying to use request graph from forge app, but I keep getting authorization error

    const query = "query something { me { user { name } } }";
    const Myrequest = await api.asUser().requestGraph(query);
    const Mydata = await Myrequest.json();

even asApp() gives the same error.
error: message
:
“This request does not contain the right authorisation scopes to provide a value for this field”

can someone help on how to give authorization ? there is only 1 user for my test now.

Hi, @AbhishekBiswas thanks for your question.
You are getting an authorization error because when running API as the user you don’t have permission to fetch the specified data. To fix this I would suggest adding the following at the end of your manifest.yml file:

permissions:
  scopes:
    - "read:jira-work"
    - "read:jira-user"
    - "read:me"
    - "read:account"

Then you should consent to the permissions in the app.

This will give your app the permissions it needs to fetch the data you need. You can find more information about permissions and scopes here.
Also to perform requests on behalf of the app and with its permissions.

- await api.asUser().requestGraph(query);
+ await api.asApp().requestGraph(query);

Please also check Product authentication.

1 Like

thanks, that resolved the permission problem, and it works as intended.

I think you should also add this permission thing with the example here