gpt4 book ai didi

c# - 在 ASP.NET Core 中使用 Azure Active Directory B2C 在 Web API 中测试云身份验证 - 返回错误 "invalid_request"

转载 作者:太空宇宙 更新时间:2023-11-03 14:53:55 25 4
gpt4 key购买 nike

我遵循本教程: https://learn.microsoft.com/fr-fr/aspnet/core/security/authentication/azure-ad-b2c-webapi?view=aspnetcore-2.1

当我测试与 Postman 的连接时,登录页面出现(我之前可以注册)但是在验证表单时,Postman 返回此错误:无效请求

我无法通过 Postman 的控制台获得有关错误的更多详细信息。

我在这里找到了更多信息: https://learn.microsoft.com/en-us/azure/active-directory/develop/active-directory-protocols-oauth-code#error-codes-for-authorization-endpoint-errors

错误代码:无效请求

描述:协议(protocol)错误,例如缺少必需的参数。

客户操作:修复并重新提交请求。这是一个开发错误,通常会在初始测试期间被发现。

但我找不到丢失的或配置错误的设置。


postman

enter image description here

enter image description here

授权网址: https://login.microsoftonline.com/trukafaire.onmicrosoft.com/oauth2/v2.0/authorize?p=B2C_1_SiUpIn

范围: https://trukafaire.onmicrosoft.com/c9f1cb20-xxxx-xxxx-xxxx-xxxxxxxxxxxx/user_impersonation openid offline_access

Visual Studio

我的 webapi 在以下地址运行(使用 visual studio 创建的模板,无需更改):https://localhost:44362/ (我测试时她正在运行)。

我的 appsettings.json :

{
"AzureAdB2C": {
"Instance": "https://login.microsoftonline.com/tfp/",
"ClientId": "c9f1cb20-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"Domain": "trukafaire.onmicrosoft.com",
"SignUpSignInPolicyId": "B2C_1_SiUpIn"
},
"Logging": {
"IncludeScopes": false,
"Debug": {
"LogLevel": {
"Default": "Warning"
}
},
"Console": {
"LogLevel": {
"Default": "Warning"
}
}
}
}

蔚蓝

申请 postman

enter image description here

应用程序 WebApi

enter image description here

最佳答案

好的,我想我找到了,我不知道是教程有误还是我漏掉了一步。

我的范围不好,教程说:

范围:

https://<holding domain name>/<api>/user_impersonation openid offline_access

在我的例子中,为了让它工作,这是我必须使用的 url:

https://<holding domain name>/api/user_impersonation

要查找范围,请转到 Azure 门户,选择“应用程序”并单击您的 API。然后点击“Published Scope”,就可以找到好的url:

enter image description here

关于c# - 在 ASP.NET Core 中使用 Azure Active Directory B2C 在 Web API 中测试云身份验证 - 返回错误 "invalid_request",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50639193/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com