我有一个位于azure b2c登录后的react前端,它允许用户在我的租户中注册的情况下登录。
然后我向我的后台发送了一个访问令牌,我使用"react-aad-msal“接收到了这个令牌:
signInAuthProvider.getAccessToken({
scopes: ["https://tenantname.onmicrosoft.com/api/scope_name"],
});当我通过一个header auth头向我的.net core3.1后端发送这个令牌时,我收到了一个401。
我正在使用addazureadbearer服务:
services.AddAuthentication(AzureADDefaults.JwtBearerAuthenticationScheme)
.AddAzureADBearer(options => Configuration.Bind("AzureAd", options));我的配置节看起来像这样:
"AzureAd": {
"Instance": "https://login.microsoftonline.com/tenantname",
"TenantId": "tenantid",
"ClientId": "clientid",
"Audience": "https://tenantname.onmicrosoft.com/api/api.access"}
我相信它正在做一些交叉检查,因为我得到了一个401,而不是一个能够连接到azure的错误。
发布于 2020-07-30 03:01:12
您需要使用b2c进行身份验证,而不是使用AAD进行身份验证
{
"AzureAdB2C": {
"Instance": "https://<your tenant name>.b2clogin.com",
"ClientId": " your client id",
"Domain": "your tenant domain",
"TenantId": "your tenant id",
"SignUpSignInPolicyId": "your policy name"
}请参阅b2c中.net核心web应用编程接口上的此github
https://stackoverflow.com/questions/63141943
复制相似问题