问题描述
我有一个与 .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 未找到签名密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)