Trying to access the REST API v3 by a forge app, I get an error 403 with message OAuth 2.0 is not enabled for this method for these API calls:
GET /rest/api/3/myself
GET /rest/api/3/user/properties/{propertyKey}
PUT /rest/api/3/user/properties/{propertyKey}
All of them have an OAuth scope defined which is declared in the permission section of the app’s manifest.yml
Hi @Marvin5 ,
I just did a little test of GET /rest/api/3/myself
and it worked for me. Here are the permissions I have in my manifest:
permissions:
scopes:
- read:jira-user
- read:jira-work
And here’s the code that makes the REST API call:
const fetchMyself = async () => {
const response = await api
.asUser()
.requestJira(`/rest/api/3/myself`);
const data = await response.json();
return data;
};
Regards,
Dugald
2 Likes
Thanks Dugald. Now it works (partly). I did not use @forge/api (within a resolver) but requestJira from @forge/bridge before.
What’s the rule on when to use @forge/api and when an API call can be made with @forge/bridge? (e.g. /rest/api/3/search works with a call via @forge/bridge)
Though now it works for GET /rest/api/3/myself
and GET /rest/api/3/user/properties/{propertyKey}
for PUT /rest/api/3/user/properties/{propertyKey}
I still get the message OAuth 2.0 is not enabled for this method
BTW: I used the Forge sample code from here and I have the permission scope write:jira-work in my manifest.
Hi @Marvin5 ,
@forge/bridge
is for use with Custom UI and runs in the browser where as @forge/api
runs in your function.
Regards,
Dugald
Regarding the OAuth 2.0 is not enabled for this method error, I tested it works when calling from a function using asUser()
. Could you provide more details about how you are calling it.
Thanks @dmorrow for your quick response an not letting me give up by giving the hint that it actually should be working.
For some strange reason, it’s working now with @forge/api
and with @forge/bridge
in my Custom UI app without any change in my code. Only in one case I got the error again, but I could not replicate it.
In case the error message will reappear I will investigate further.
1 Like
I’m glad it’s working @Marvin5