简体   繁体   中英

ASP.NET Core 2.0 resource access_token

How do I acquire a OpenIdConnectParameterNames.AccessToken for a given resource (ex/ Power BI)?

I created a new ASP.NET Core 2.0 MVC project in VS2017 that uses AAD for authentication. Given an authenticated user, I need to get a resource access_token so that I can then make web api calls to said resource.

For my specific case, I'm trying to access Power BI content but this also applies to other resources such as graphQL.

So far I've managed to get an idtoken which unfortunately doesn't seem to authenticate against the resource. My attempts to fetch the access_token result in null .

You should use ADAL/MSAL to get the access token in OnAuthorizationCodeReceived event of OpenID Connect OWIN middleware . And ensure you have set the response type of OpenIdConnect Options to "code id_token" to implement Hybrid flow . With ADAL library , specify the resource(PowerBi rest endpoint in your scenario) in AcquireTokenByAuthorizationCodeAsync function .

Please refer to article : ASP.NET Core 2.0 Azure AD Authentication .@juunas provides the explanation and code sample in this article .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM