【问题标题】:using MSAL Authentication in WASM Application calls to Microsoft Graph and custom API在 WASM 应用程序调用 Microsoft Graph 和自定义 API 中使用 MSAL 身份验证
【发布时间】:2021-03-25 14:18:12
【问题描述】:

我实现了这个以使用 WASM 独立应用程序登录用户。

builder.Services.AddMsalAuthentication(options =>
            {
                builder.Configuration.Bind("AzureAd", options.ProviderOptions.Authentication);}

效果很好。当我尝试为图形和我的 api 添加范围时。它不允许登录。

builder.Services.AddMsalAuthentication(options =>
            {
                builder.Configuration.Bind("AzureAd", options.ProviderOptions.Authentication);
   options.ProviderOptions.DefaultAccessTokenScopes.Add("https://graph.microsoft.com/User.Read");               
   options.ProviderOptions.DefaultAccessTokenScopes.Add("https://xsc.com/xxEmployees.Read.All");
) 

错误显示 AADSTS28000:输入参数范围的提供值无效,因为它包含多个资源。如何让它工作?
我查看了 AcquireTokenSilent 它使用 Microsoft.Identity.Client 这是我唯一的选择。如果是我的下一个问题是如何获取经过身份验证的用户 AuthenticationStateprovider 并为 AcquireTokenSilent 方法创建一个 IAccount。任何想法或其他方法来尝试这个将不胜感激。

【问题讨论】:

    标签: azure-active-directory webassembly msal


    【解决方案1】:

    Msal 基于 azure ad,因此根据 azure ad 的政策,您不能同时为两种或更多类型的范围生成访问令牌。

    This page也提到过,唯一的办法好像是单独生成token,调用api两次。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-22
      • 2017-09-20
      • 2021-12-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多