Playing in Graph Explorer with my MS account I get the following information:
User Principal Name: ******@hotmail.com
Id: dd81....
DisplayName: Giorgio Sfiligoi
Preferred Language: it-IT
email: ******@hotmail.com
Running the old sample (for desktop) 'OneDriveApiBrowser' reports the same Id.
Then I tried the samples in https://github.com/Azure-Samples/ms-identity-dotnetcore-maui/tree/main in .net9.0.
I added a page that provides status information:
protected override async void OnAppearing()
{
base.OnAppearing();
try
{
var user = await PublicClientSingleton.Instance.MSGraphHelper.GetMeAsync();
if (user == null) await Shell.Current.DisplayAlert("Error", "Cannot find GraphUser", "OK");
else
{
StringBuilder sb = new StringBuilder();
sb.Append("Name : "); sb.AppendLine(user.DisplayName);
sb.Append("Id : "); sb.AppendLine(user.Id);
sb.Append("email : "); sb.AppendLine(user.Mail);
sb.Append("Preferred language : "); sb.AppendLine(user.PreferredLanguage);
// --------
if (user.Drive == null) sb.AppendLine("DRIVE NULL"); else sb.AppendLine("DRIVE OK");
if (user.Drives == null) sb.AppendLine("DRIVES NULL"); else sb.AppendLine("DRIVES OK");
if (user.PermissionGrants == null) sb.AppendLine("PERMISSION GRANTS NULL"); else sb.AppendLine("PERMISSION GRANTS OK");
result.Text = sb.ToString();
}
}
catch (MsalUiRequiredException ex)
{
await Shell.Current.DisplayAlert("EXCEPTION", ex.Message, "OK");
await PublicClientSingleton.Instance.SignOutAsync();
await Shell.Current.GoToAsync("..");
}
}
'result' is the x:Name of a Editor item in the page.
This reports:
DisplayName : Giorgio Sfiligoi
Id : ac34....
email :
Preferred language :
DRIVE NULL
DRIVES NULL
PERMISSION GRANTS NULL
Notice that the ID is different, and the fields 'email' and 'Preferred language' remain empty.
This "new" ID shows the same DisplayName, but I think that actually it points to a different user.
Can anybody clarify this discrepancy?