Acquiring an Access token by using JWT used for AzureBearerAuthentication

后端 未结 1 1158
梦如初夏
梦如初夏 2021-01-21 04:39

I have a WebApi app that is using Windows Azure Active Directory Bearer Authentication to authenticate users. After the user is authenticated, I want to query Azure\'s Graph Ap

相关标签:
1条回答
  • 2021-01-21 05:31

    That is indeed somewhat hacky :-) see https://github.com/AzureADSamples/WebAPI-OnBehalfOf-DotNet for a way in which you can retrieve the incoming token through the ClaimsPrincipal. It boils down to passing TokenValidationParameters = new TokenValidationParameters{ SaveSigninToken = true } in the options and retrieving in from your controller or filter code via

    var bootstrapContext = ClaimsPrincipal.Current.Identities.First().BootstrapContext as System.IdentityModel.Tokens.BootstrapContext; 
    
    0 讨论(0)
提交回复
热议问题