微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Microsoft Identity OIDC:受众“00000002-0000-0000-c000-000000000000”无效

如何解决Microsoft Identity OIDC:受众“00000002-0000-0000-c000-000000000000”无效

相信我,我尝试了所有可能的选项,阅读了所有关于 stack-overflow 的帖子,没有任何效果

我正在使用带有 oauth2 的 swagger UI。我点击执行,总是得到相同的响应。

带有 401 的错误消息:www-authenticate: Bearer error="invalid_token"error_description="观众 '00000002-0000-0000-c000-000000000000' 无效"

public void ConfigureServices(IServiceCollection services)
{
    services.AddAuthentication(BeararAuth)
        .AddMicrosoftIdentityWebApi(Configuration)
        .EnabletokenAcquisitionToCallDownstreamApi()
        .AddInMemoryTokenCaches();

    services.AddSwaggerGen(c =>
    {
            c.OperationFilter<AuthorizeCheckOperationFilter>(Configuration["AzureAd:ClientId"]);
            c.SwaggerDoc("v1",new OpenApiInfo { Title = "WebApplication4",Version = "v1" });
            c.AddSecurityDeFinition("oauth2",new OpenApiSecurityScheme
            {
                In = ParameterLocation.Header,Type = SecuritySchemeType.OAuth2,Flows = new OpenApiOAuthFlows
                {
                    AuthorizationCode = new OpenApiOAuthFlow
                    {
                        AuthorizationUrl = new Uri("https://login.microsoftonline.com/common/oauth2/authorize"),TokenUrl = new Uri("https://login.microsoftonline.com/common/oauth2/token"),Scopes = new Dictionary<string,string>
                        {
                          {"User.Read","User Read scope"},{"access_as_user","access APIs as user" },{ $"api://{Configuration["AzureAd:ClientId"]}/access_as_user","Application API Permissions" }
                        }
                    }
                 }
              });
         });
      }

请帮我解决这个问题。

我可以使用身份验证流程成功登录到swagger;令牌生成

当我将该令牌粘贴到 https://jwt.io 中时,

它向我显示 aud 的值为 '00000002-0000-0000-c000-000000000000'。

请帮我解决这个问题。我在 azure 广告方面做错了什么,或者后端 api 方面缺少什么。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。