I've an ASP.NET Core application using ASP.NET Core Identity and trying to authenticate against Azure AD.
services.AddAuthentication()
.AddOpenIdConnect("AzureAD", "Azure AD", option =>
{
option.ClientId = Configuration["AzureAD:AppId"];
option.ClientSecret = "abc";
option.Authority = string.Format(Configuration["AzureAd:AadInstance"], Configuration["AzureAd:Tenant"]);
option.SignedOutRedirectUri = Configuration["AzureAd:PostLogoutRedirectUri"];
option.ResponseType = OpenIdConnectResponseType.CodeIdToken;
option.SaveTokens = true;
option.SignInScheme = IdentityConstants.ExternalScheme;
option.Events = new OpenIdConnectEvents
{
OnRemoteFailure = OnAuthenticationFailed,
};
});
Everything works fine, the user can login using its credentials.
Now i'm trying to access Microsoft Graph in order to receive the user's email address (it's not send as claim in the id_token). But when I use the received access_token from the login flow the Graph aPI returns an error:
Code: InvalidAuthenticationToken
Message: CompactToken parsing failed with error code: -2147184105
When I look at the access_token it looks weird. It's not a valid JWT.
AQABAAAAAABHh4kmS_aKT5XrjzxRAtHzymKlkayx9UvCfyg_uHq1prmSP8f0Mi5BfiqkdIZeqJsBbm9SSbDbMrQ0JgNa6pa6M97IjVr6ZHdtt3ryT8vns_kz5BxkdJFkL79Ql3ywzyKldfLuX9jwq1eCgQ1MMdqKUDW4q5g38...
What I'm doing wrong?