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

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

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

問題描述

限時送ChatGPT賬號..

我有一個與 .Net Core 2.2 API 后端接口的 Angular 7 應用程序.這是與 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 正確進行身份驗證,并且我得到了一個有效的 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 方面,我創建了一個簡單的測試 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: 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 調用代碼也很簡單:

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 的標準 GET 請求調用 它可以正常工作.

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));

所有選項都在 appsettings.json 中正確設置(例如 ClientId、TenantId 等),并且此處的 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 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
                });

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

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

相關文檔推薦

ASP.NET Core authenticating with Azure Active Directory and persisting custom Claims across requests(ASP.NET Core 使用 Azure Active Directory 進行身份驗證并跨請求保留自定義聲明)
ASP.NET Core 2.0 Web API Azure Ad v2 Token Authorization not working(ASP.NET Core 2.0 Web API Azure Ad v2 令牌授權不起作用)
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(如何獲取守護進程或服務器到 C# ASP.NET Web API 的 Azure AD OAuth2 訪問令牌和刷新令牌) - IT屋-程序員軟件開發技
.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(異步調用時 Azure KeyVault Active Directory AcquireTokenAsync 超時)
主站蜘蛛池模板: 日韩在线免费视频 | 91一区二区三区在线观看 | 成人午夜影院 | 久久国际精品 | 成人黄色av网址 | 精品国产欧美 | 红桃视频一区二区三区免费 | 久久久久国产一区二区三区四区 | 久久久久国产精品免费免费搜索 | 99精品久久久久久 | 欧美日韩专区 | 国产精品久久久久久久久久久久久 | 成人av免费 | 欧美日韩在线一区二区 | 欧美日韩三级 | 美女拍拍拍网站 | 特级毛片 | 91久久精品国产91久久 | 亚洲成人网在线观看 | 国产成人精品一区二区三区在线 | 最新av在线播放 | 国产免费一级一级 | 一本一道久久a久久精品综合 | 91av在线不卡 | 九九免费视频 | 国产99久久精品一区二区永久免费 | 国产不卡在线播放 | 亚洲在线| 欧美久久一区二区 | 91欧美激情一区二区三区成人 | 久久精品欧美一区二区三区不卡 | 国产 欧美 日韩 一区 | 国产一区不卡 | 成人性生交大片免费看r链接 | 国产精品99久久久精品免费观看 | 羞羞视频网站免费观看 | 欧美国产精品一区二区三区 | 五月天国产在线 | 欧美黄在线观看 | 国产电影一区 | 亚洲97|