久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

承載錯誤 - invalid_token - 未找到簽名密鑰

Bearer error - invalid_token - The signature key was not found(承載錯誤 - invalid_token - 未找到簽名密鑰)
本文介紹了承載錯誤 - invalid_token - 未找到簽名密鑰的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

限時送ChatGPT賬號..

我有一個與 .Net Core 2.2 API 后端接口的 Angular 7 應(yīng)用程序.這是與 Azure Active Directory 的接口.

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

在 Angular 7 方面,它正在通過 AAD 正確進(jìn)行身份驗(yàn)證,并且我得到了一個有效的 JWT,如 jwt.io.

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

在 .Net Core API 方面,我創(chuàng)建了一個簡單的測試 API,其中包含 [Authorize].

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

當(dāng)我從 Angular 調(diào)用此方法時,添加 Bearer 令牌后,我得到(如 Chrome 調(diào)試工具、網(wǎng)絡(luò)選項(xiàng)卡、標(biāo)題"中所示):

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: Bearer error="invalid_token", error_description="The signature key was not found"

帶有HTTP/1.1 401 Unauthorized.

簡單的測試 API 是:

The simplistic test API is:

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

Angular 調(diào)用代碼也很簡單:

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

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

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

如果我刪除 [Authorize] 屬性并將其作為來自 Angular 的標(biāo)準(zhǔn) GET 請求調(diào)用 它可以正常工作.

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

我的 Startup.cs 包含:

My Startup.cs contains:

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

所有選項(xiàng)都在 appsettings.json 中正確設(shè)置(例如 ClientId、TenantId 等),并且此處的 options 按預(yù)期填充.

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

推薦答案

我也遇到了同樣的問題.我錯過了權(quán)限..確保權(quán)限和 api 名稱現(xiàn)在正確,啟動文件中配置服務(wù)中的這段代碼對我有用:

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

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

這篇關(guān)于承載錯誤 - invalid_token - 未找到簽名密鑰的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

ASP.NET Core authenticating with Azure Active Directory and persisting custom Claims across requests(ASP.NET Core 使用 Azure Active Directory 進(jìn)行身份驗(yàn)證并跨請求保留自定義聲明)
ASP.NET Core 2.0 Web API Azure Ad v2 Token Authorization not working(ASP.NET Core 2.0 Web API Azure Ad v2 令牌授權(quán)不起作用)
ASP Core Azure Active Directory Login use roles(ASP Core Azure Active Directory 登錄使用角色)
How do I get Azure AD OAuth2 Access Token and Refresh token for Daemon or Server to C# ASP.NET Web API(如何獲取守護(hù)進(jìn)程或服務(wù)器到 C# ASP.NET Web API 的 Azure AD OAuth2 訪問令牌和刷新令牌) - IT屋-程序員軟件開發(fā)技
.Net Core 2.0 - Get AAD access token to use with Microsoft Graph(.Net Core 2.0 - 獲取 AAD 訪問令牌以與 Microsoft Graph 一起使用)
Azure KeyVault Active Directory AcquireTokenAsync timeout when called asynchronously(異步調(diào)用時 Azure KeyVault Active Directory AcquireTokenAsync 超時)
主站蜘蛛池模板: 久久久久久久国产精品 | 欧美综合一区 | 国产精品一区在线观看 | 免费毛片视频 | 五月婷婷在线观看 | 成人在线视频网站 | 狠狠五月天 | 性久久久久| 日韩成人在线免费观看 | 亚洲日本中文字幕 | 乳色吐息在线观看 | 国产一区二区久久 | 福利色导航| 日韩精品一区二区三区四区 | 亚洲福利在线观看 | 在线视频一区二区三区 | 69免费视频 | 日韩欧美国产综合 | 久久久久免费 | 狠狠做深爱婷婷综合一区 | 日韩欧美国产一区二区三区 | 激情高潮到大叫狂喷水 | 国产精品入口夜色视频大尺度 | 国产精品网站在线观看 | 亚洲精品成人网 | av免费网站| 在线观看日韩欧美 | av一二三区| 国产精品免费一区二区三区 | 午夜不卡视频 | 国产精品久久免费 | 成人午夜视频在线观看 | 国产黄a三级 | 六月天婷婷 | 国产一级片在线 | 在线一区二区三区四区 | 亚洲三级视频 | 天天干夜夜爱 | 日韩欧美在线播放 | av黄页| 涩涩在线 |