How to get Current User Data in Jira using Forge Custom UI

Am trying to get current Login Users data in Jira using Forge custom UI but it throws error

{"errorMessages":["OAuth 2.0 is not enabled for method: GET /wiki/rest/api/user/current"]}

Here is the code


import api, { route } from "@forge/api";

const response = await api.asUser().requestJira(route`/wiki/rest/api/user/current`);
console.log(`Response: ${response.status} ${response.statusText}`);
console.log(await response.json());

Hi @EsedoFredrick,

Based on this code snippet, you are calling Confluence Cloud’s Get current user API inside your Forge app for Jira. Kindly try Jira Cloud’s Get current user API and that should return Jira’s current user.

Do let us know how it goes.

Ian

Thanks @iragudo for getting back to me. The Api you sent is returning something else which is not my data

The accountid, emailAddress and displayname is not my data. its something else.
for instance the displayname is showing my application name: Ncra-App,
the emailAddress is showing: 26e37c15-baab-4907-9752-c58ab851c0d9@connect.atlassian.com

Hi @EsedoFredrick ,

Based on the response, it seems you are using asApp instead of asUser which is why you are getting the app’s credentials.

Can you try this instead?

await api.asUser().requestJira(route`/rest/api/3/myself`);

Cheers,
Ian

Thank you so much