![](/img/trans.png)
[英]Azure Active Directory: Bearer error=“invalid_token”, error_description=“The signature is invalid”
[英].NET 5 API and React UI authentication using Azure AD B2C - Bearer error="invalid_token", error_description="The signature is invalid"
作為新項目的一部分,我正在嘗試使用 Azure AD B2C 將身份驗證與 React 應用程序和 .NET 5 API 集成。 我想我快到了,但是在發出請求時,我收到一條帶有“Bearer error="invalid_token", error_description="簽名無效"的 401 消息。
在我的 Startup.cs 中,我將其定義如下:
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApi(Configuration.GetSection("AzureAdB2C"))
我的測試 controller 端點是這樣寫的:
[Authorize]
[HttpGet("private")]
public IActionResult Private()
{
return Ok(new
{
Message = "Hello from a private endpoint! You need to be authenticated to see this."
});
}
我的 appsettings.json 中有我的 AzureADB2C 設置,如下所示:
"AzureAdB2C": {
"Instance": "https://login.microsoftonline.com/",
"ClientId": "<API Client Id (GUID)>",
/*
You need specify the TenantId only if you want to accept access tokens from a single tenant
(line-of-business app).
Otherwise, you can leave them set to common.
This can be:
- A GUID (Tenant ID = Directory ID)
- 'common' (any organization and personal accounts)
- 'organizations' (any organization)
- 'consumers' (Microsoft personal accounts)
*/
"TenantId": "common"
},
I'm wrestling with a mixture of out of date documentation in some cases and the examples given use a node.js API with no .NET API examples so I've tried to piece together everything as best I can and I'm not quite sure what I我失蹤了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.