microsoftgraph / microsoftgraph/msgraph-sdk-java
getMail() method is returning the email alias instead of real email address
Personne n'a encore pris cette issue.
- Langage dominant
- Java
- Étoiles
- 444
- Forks
- 154
- Merge moyen
- 18 h 28 min
- PR mergées (30 j)
- 4
Description
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:
- user get authenticated using the account danielrealuser@gmail.com;
- the user get authenticated, however, the real email address is randomvalue@outlook.com;
- instead or returning randomvalue@outlook.com it returns danielrealuser@gmail.com.
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_
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par getUserProfile et l’appel graphClient.me().get(), puis examinez comment User.getMail() mappe la réponse du profil Microsoft Graph. Comparez le comportement de l’alias et de l’adresse réelle renvoyés avec les scopes indiqués et le comportement actuel du SDK. C’est terminé lorsque la recherche du profil renvoie l’adresse attendue ou documente clairement la limitation de l’API, avec un test de régression si le SDK contrôle le mappage.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- java
- Domaine
- api, authentication
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100