I’m struggling to fetch the email address of the currently authenticated user when working with Jira Cloud API. I’ve tried a couple of approaches but haven’t had success yet.
First, I looked into using OAuth with OpenID Connect to get email information from the ID token, but it seems Jira Cloud doesn’t support the OpenID protocol for this purpose.
I also attempted to use the REST API endpoint for getting user information, but that approach appears to require already knowing the email address, which defeats the purpose since that’s exactly what I’m trying to obtain.
Has anyone found a working solution for retrieving the current user’s email address through the Jira Cloud API? What’s the recommended approach for this scenario?
Yeah, /myself should work but won’t return email if your admin enabled privacy settings. Check the response first - no email field means you’ll need /rest/api/3/user/search with your accountId as the parameter. It’s a workaround but gets the job done when privacy’s locked down.
The /rest/api/3/myself endpoint is your best bet, but heads up - I’ve hit some weird inconsistencies with it. The email field name changes between Jira versions. Sometimes it’s emailAddress, sometimes just email. Check both in your code.
Also ran into rate limiting issues where it worked fine in testing but crashed in production. Handle those 429 responses if you’re hitting it a lot.
One gotcha: some orgs disable email exposure completely in their Atlassian admin settings. Have a backup plan ready if the email field keeps coming back null.
Use the /rest/api/3/myself endpoint to get the authenticated user’s email in Jira Cloud. This endpoint returns details about whoever’s currently logged in, including their email. Make sure you’re sending proper auth headers with your API token or OAuth token. I’ve found it consistently returns a JSON object with accountId, displayName, and emailAddress. Just double-check your token has permissions to access user data - some setups restrict this.