首页 > 解决方案 > 迁移到 .net5 后的 Blazor webassembly azure 广告身份验证问题

问题描述

迁移到 .net5 后的 Blazor webassembly azure 广告身份验证问题

错误:AADSTS28000:为输入参数范围提供的值无效,因为它包含多个资源。范围https://graph.microsoft.com/User.Read api://861be009-5e73-4c6c-a095-b6e193522222/API。访问 openid 配置文件无效。

范围代码(网络程序集):

    builder.Configuration.Bind("AzureAd", options.ProviderOptions.Authentication);
    options.ProviderOptions.DefaultAccessTokenScopes.Add("https://graph.microsoft.com/User.Read");
    options.ProviderOptions.DefaultAccessTokenScopes.Add("api://861be009-5e73-4c6c-a095-b6e193522222/API.Access");

标签: azure-active-directoryblazorwebassembly

解决方案


当您请求令牌时,您在范围内使用不同的资源端点,即 Microsoft Graph 和您的自定义 API,这是不正确的,您可以只为一种资源请求令牌,因为一个令牌只能有一个受众.


推荐阅读