I have an ASP.NET Core API secured using the AzureADBearer authentication method.
Following the example laid our here: https://github.com/Azure-Samples/active-directory-dotnet-webapp-webapi-openidconnect-aspnetcore
Calls to the API are secured using a bearer token that is generated with ADAL.net with this method.
private async Task<string> getToken()
{
AuthenticationResult result = null;
string userObjectID = (User.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier"))?.Value;
// Using ADAL.Net, get a bearer token to access the TodoListService
AuthenticationContext authContext = new AuthenticationContext(AzureAdOptions.Settings.Authority, new NaiveSessionCache(userObjectID, HttpContext.Session));
ClientCredential credential = new ClientCredential(AzureAdOptions.Settings.ClientId, AzureAdOptions.Settings.ClientSecret);
result = await authContext.AcquireTokenAsync(AzureAdOptions.Settings.TodoListResourceId, credential);
return result.AccessToken;
}
However, when i look at the claims that the API receives.. there is no identifier that appears as being unique to the user. The Nameidentifier claim is identical for every user i generate the token for.
The objectid generated in the above code - is the only unique aspect in the generation of the token, and that doesn't seem to matter in the claims represented in the APIs de-construction of the token.
Any thoughts on how i can get any sort of user unique ID across to the API? That could be email, SID anything i can use..