承载错误 - vpn下载 invalid_token - 未找到签名密钥

658

vpn下载 vpn free vpn free 本文介绍了承载错误 - invalid_token - 未找到签名密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我有一个与 .Net Core 2.2 vpn free API 后端接口的 Angular 7 应用程序.这是与 Azure Active 免费vpn Directory 的接口.

I have an Angular 7 application vpn free interfacing with a .Net Core 2.2 API back-end. This is interfacing with Azure Active free vpn Directory.

在 Angular 7 方面,它正在通过 AAD vpn下载 正确进行身份验证,并且我得到了一个有效的 JWT,如 jwt.io.

On the Angular 7 side, it is authenticating properly with 免费vpn下载 AAD and I am getting a vpn free valid 免费vpn JWT back as vpn下载 verified on 免费vpn jwt.io.

在 免费vpn .Net 免费vpn Core API 方面,我创建了一个简单的测试 API,其中包含 [Authorize].

On the .Net Core API side I created a simple test API that has [Authorize] on it.

当我从 Angular 调用此方法时,添加 Bearer 令牌后,我得到(如 Chrome 调试工具、网络选项卡、标题"中所示):

When I call this method from Angular, after adding the Bearer token, I am getting (as seen in Chrome Debug Tools, Network tab, "Headers"):

WWW-Authenticate: Bearer error="invalid_token", error_description="The未找到签名密钥"

WWW-Authenticate: 免费vpn下载 Bearer error="invalid_token", error_description="The signature key was not found"

带有HTTP/1.1 免费vpn 401 Unauthorized.

简单的测试 API 是:

The simplistic test API is:

    [Route("Secure")]
    [Authorize]
    public IActionResult Secure() => Ok("Secure works");

Angular 调用代码也很简单:

The Angular calling code vpn free is also as simple as I can get it:

    let params : any = {
    vpn下载     responseType: free vpn 'text',
        headers: new HttpHeaders({
           免费vpn下载  "Authorization": "Bearer " + token,
   免费vpn下载     免费vpn下载 vpn下载  vpn下载     "Content-Type": "application/json"
      vpn free   })
    }

    this.http
     vpn vpn下载 free    .get("https://localhost:5001/api/azureauth/secure", params)
        .subscribe(
            data => vpn free { },
        vpn下载     error => { console.error(error); }
    free vpn     );

如果我删除 [Authorize] 属性并将其作为来自 Angular 的标准 GET 请求调用 它可以正常工作.

If I remove the [Authorize] attribute and just call this as a 免费vpn standard GET request from Angular it works fine.

我的 Startup.cs 包含:

My Startup.cs contains:

 免费vpn        services
   free vpn         免费vpn  .AddAuthentication(AzureADDefaults.AuthenticationScheme)
         vpn free    .AddAzureADBearer(options => this.Configuration.Bind("AzureAd", options));

所有选项都在 appsettings.json 中正确设置(例如 ClientId、TenantId vpn下载 等),并且此处的 options 按预期填充.

The options are all properly set (such as ClientId, TenantId, etc) in the appsettings.json and options here is populating as expected.

推荐答案

我也遇到了同样的问题.我错过了权限..确保权限和 api 名称现在正确,启动文件中配置服务中的这段代码对我有用:

I was facing the same issue. i was missing the authority..make sure authority and 免费vpn api 免费vpn 免费vpn下载 name vpn free is correct now this code in configure services in startup 免费vpn file works for me:

services.AddAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme)
         free vpn    vpn下载     .AddIdentityServerAuthentication( x =>
 vpn下载  vpn下载          vpn free      {
                    x.Authority = vpn free "http://localhost:5000"; //idp address
          vpn下载           x.RequireHttpsMetadata = free vpn false;
   免费vpn下载         free vpn          vpn free x.ApiName = "api2"; //api name
                });

这篇关于承载错误 - invalid_token - 免费vpn 未找到签名密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

C# 中的多播委托奇怪行为?
Multicast 免费vpn delegate weird behavior in C#?(C# 中的多播委托奇怪行为?)...
2023-11-11 C#/.NET开发问题
vpn下载 6

参数计数与调用不匹配?
Parameter count mismatch with Invoke?(参数计数与调用不匹配?)...
2023-11-11 C#/.NET开发问题
26

如何将代表存储在列表中
How to store delegates in a List(如何将代表存储在列表中)...
2023-11-11 C#/.NET开发问题
6

代表如何工作(在后台)?
How delegates work (in the background)?(代表如何工作(在后台)?)...
2023-11-11 C#/.NET开发问题
5

没有 EndInvoke 的 C# 异步调用?
C# Asynchronous call without EndInvoke?(没有 EndInvoke 的 C# 异步调用?)...
2023-11-11 C#/.NET开发问题
2

Delegate.CreateDelegate() 和泛型:错误绑定到目标方法
Delegate.CreateDelegate() and generics: Error binding to target method(Delegate.CreateDelegate() 和泛型:错误绑定到目标方法)...
2023-11-11 C#/.NET开发问题
14