从Azure AD支持的.NET Framework MVC应用程序获取访问令牌



我有一个.NET Framework MVC应用程序,该应用程序为基于会话的Azure AD配置了身份验证。用户登录后,我需要获得前端的访问承载令牌和刷新令牌,以用于Power BI javascript嵌入。我无法找到从服务器获得访问权限的方法。

以下是Start.Auth.cs的设置方式:

app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions ());
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = clientId,
Authority = authority,
RedirectUri = redirectUri                    
});

我需要一个基于用户的身份验证访问令牌来传递给Power BI javascript嵌入,以便识别用户,而不是基于客户端id/客户端机密服务器的令牌。

PowerBI团队提供了一个.NET Core示例。

https://github.com/microsoft/PowerBI-Developer-Samples/blob/../NetCore-Sample/Pages/Index.cshtml.cs

当你查看时,还有更多关于如何获得授权码的文档

  • 获取Azure AD访问令牌

最新更新