Weird behavior of Cloud "myself" API response

Hi folks,
I was using “/rest/api/3/myself” this api to get the emailAddress. But in response we are not able to get it.Previously i was able to get the emailAddress. Some changes happened in api response.

This is the JavaScript code for getting the myself response

AP.require("request", function (request) {
          request({
            url: "/rest/api/3/myself",

            success: function (response) {
              // convert the string response to JSON
              response = JSON.parse(response);
              //function(xxxxxxxxx);

              // dump out the response to the console
              console.log(response);

            },
            error: function () {
              console.log(arguments);
            }
          });
});

This is the response

Object { 
self: "https://#######.atlassian.net/rest/api/2/user?accountId=######", 
key: "admin", 
accountId: "######", 
name: "admin",
avatarUrls: {…}, 
displayName: "######", 
active: true,
timeZone: "Asia/Kolkata", 
locale: "en_US", groups: {…}, … }

In this response I am not getting the emailaddress. If anybody can help me out please let me know .TIA

2 Likes

Hi @Sowmya
Enforcing privacy of email address for GDPR may have been recently enforced.
There are some details here:
https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide/

Regards,
David

1 Like

Thanks for your answer. Actually i want to know how we can get the email Id of current logged in user. So that’s why i am calling the myself api. Is there any way to get the email Id.

Why we need a email id since we want to generate the basic authorization token which is the combination of email id and apiToken in the form of base64.

Example: HTTP Header
Authorization : Basic Y29tLmVtcHlyYS5qaXJhLsdcEBjb25uZWN0LmF0bG (email + apiToken )

How will get this email of current logged in user ?

Can we get the email id from this.
Context

AP.user.getCurrentUser(function(user) {
  console.log("The User Email is", user.emailAddress);
});

Regards,
Sowmya

1 Like

Hi @Sowmya,

Afaik, retrieval of the email address depends on the privacy setting of the user. So even if you requested access to the Email API, if the user wishes to set their email address to private, there’s really nothing you can do

Sample scenario:

I cannot see email address (in APIs, User Pickers, etc) anymore

When profile visibility is enabled, email is private by default. This means that other users cannot see a users email address and it will be replaced with a placeholder value.

To resolve this, the email needs to be set to something other than private for each user in the new profile visibility settings screen (not the old one with the radio buttons):

  1. Go to the user settings page for your profile: https://id.atlassian.com/manage-profile/profile-and-visibility

image

  1. Change the profile visibility of the users email:

With this, it doesn’t matter if you’re calling the API as an app or as an integration, if the users have set their email to private then there’s nothing the Email API can do to get that.

Hope this helps.

Cheers,
Anne

1 Like

Hi @Sowmya,
@acalantog is right. Check the privacy settings and try it again.