How to fetch logged in user's emailid

I am making an atlassian forge app using custom ui.
I need the loggedin users email…How to get it

Hi @shubhankarkumarsingh
In most cases, calling the ‘Myself REST API’ (https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-myself/#api-rest-api-3-myself-get) should suffice to retrieve information about the current user interacting with your app.


image
image

i am getting undefined in console

Do I need some permissions

It’s always a good idea to check the “Scopes” section in the REST API documentation.
For example, the endpoint /rest/api/3/myself requires the read:jira-user scope in your manifest.yml under permissions -> scopes.

I am using a custom ui…i hear this method is not available there
image

Clarification:

  1. When creating a Custom UI, you should use requestJira from @forge/bridge. Here’s an example of how to do this:
import { requestJira } from '@forge/bridge';

/* ... */

const response = await requestJira(
  `/rest/api/3/issue/${issueKey}/properties/${propertyKey}`,
  {
    headers: {
      Accept: 'application/json',
    },
  }
);

const data = await response.json();
console.log('Data:', data);

  1. When creating a web trigger, invokable function, custom field, or any other Forge back-end function, use api.asUser().requestJira from @forge/api. Here’s how to implement it:
import api, { route } from '@forge/api';

/* ... */

const response = await api.asUser().requestJira(
  route`/rest/api/3/issue/${propertyPrefix}/properties/${propertyKey}`,
  {
    headers: {
      Accept: 'application/json',
    },
  }
);

const data = await response.json();
console.log('Data:', data);

Key Notes:

  • Use @forge/bridge for Custom UI components to interact with Jira.
  • Use @forge/api for back-end functions (e.g., web triggers, invokable functions) to perform Jira API requests on behalf of a user.

Both methods follow similar patterns for API requests, but ensure you’re using the correct module (@forge/bridge vs. @forge/api) depending on the type of functionality you’re implementing.