Skip to content

getMail() method is returning the email alias instead of real email address #2389

@danvc

Description

@danvc

Describe the bug

I'm using the SDK in order to allow the user to get authenticated on my platform.

The problem that I'm facing is that the getMail() is returning the email alias instead of the real email. For example:

Expected behavior

When requesting the data regarding the user, it should return the real user email in the property getMail, however, it gets the alias used to authenticate on Outlook.

How to reproduce

These are the scopes that I'm using (and I'll user more later not related to this topic):
"email",
"Mail.Read",
"Mail.Read.Shared",
"Mail.ReadBasic",
"Mail.ReadBasic.Shared",
"offline_access",
"openid",
"profile",
"User.Read.all",
"User.ReadBasic.All",
"ExternalUserProfile.Read.All"

Code implementation

    public User getUserProfile(String accessToken) {
        GraphServiceClient graphClient = createGraphServiceClient(accessToken);
        return graphClient.me().get();
    }

            IAuthenticationResult authResult = this.exchangeCodeForTokens(authCode);
            User user = this.getUserProfile(authResult.accessToken());

            // Get user profile using the access token
            return new MicrosoftUserData(
                    user.getId(),
                    user.getGivenName(),
                    user.getSurname(),
                    user.getMail(),
                    authResult.accessToken(),
                    authResult.accessToken(), // Use refresh token instead of access token twice
                    user.getDisplayName(),
                    getProfilePictureDataUrl(authResult.accessToken())
            );

SDK Version

No response

Latest version known to work for scenario above?

6.40.0

Known Workarounds

No response

Debug output

Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_

Metadata

Metadata

Assignees

No one assigned

    Labels

    status:waiting-for-triageAn issue that is yet to be reviewed or assignedtype:bugA broken experience

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions