Hi,
I am trying to fetch the information for the currently logged-in user in my Jira Cloud plugin. I am mainly interesting in the Account ID, Name, Email Address of the user.
I am using Atlasian Connect Express application.
From my iFrame application (written in Angular), when I execute the below function, it returns me only the Account Id of the user.
AP.user.getCurrentUser(function(user: any) {
console.log("The Atlassian Account ID is", user.atlassianAccountId);
});
However, when I try the Request module, I get 403: Forbidden
AP.request('/rest/api/user/current')
.then(data => alert(data.body))
.catch(e => alert(e.err));
I will appreciate if someone can help me to figure out the underlying issue, please.
Regards,
Ahmad Qarshi
I think you should be doing a GET to /rest/api/3/myself and not /rest/api/user/current . Note that you’ll need to use the read scope in your descriptor.
2 Likes
Hi Daniel,
Thanks for your prompt response. I have already set the read
scope in the descriptor file but that didn’t work.
However, when I tried with a GET to /rest/api/3/myself, it did work and I received the required data.
By the way, what could be the reason for the failure of the /rest/api/user/current
Thanks a lot for the help.
Welcome to the Atlassian Developer Community, @AhmadQarshi1!
Chiming in here, as @danielwester highlighted, Jira Cloud uses GET /rest/api/3/myself
to get the current user.
Looking at the one you used - /rest/api/user/current
- by any chance are you referencing Confluence Cloud’s Get current user API instead of Jira Cloud’s?
Cheers,
Ian
Thank you @ianRagudo.
No I am using Jira Cloud. The very last function found here
Thanks,
Ahmad Qarshi
It’s been more than one year, but for what is worth and maybe other looking-for users may find an answer here. I had the same issue, the solution in my case was to add scopes in the descriptor
https://developer.atlassian.com/cloud/jira/software/scopes-for-connect-apps/