Asp.net core Azure b2c.Net核心后端始终为前端提供401前端响应访问令牌
我有一个react前端,它位于azure b2c登录的后面,如果用户在我的租户中注册,它允许用户登录 然后,我使用“react aad msal”将一个访问令牌发送到我的后台服务器: 当我通过无记名身份验证头将此令牌发送到我的.net core 3.1后端时,我会收到一个401 我正在使用addazureadbearer服务:Asp.net core Azure b2c.Net核心后端始终为前端提供401前端响应访问令牌,asp.net-core,react-redux,azure-active-directory,azure-ad-b2c,auth-token,Asp.net Core,React Redux,Azure Active Directory,Azure Ad B2c,Auth Token,我有一个react前端,它位于azure b2c登录的后面,如果用户在我的租户中注册,它允许用户登录 然后,我使用“react aad msal”将一个访问令牌发送到我的后台服务器: 当我通过无记名身份验证头将此令牌发送到我的.net core 3.1后端时,我会收到一个401 我正在使用addazureadbearer服务: services.AddAuthentication(AzureADDefaults.JwtBearerAuthenticationScheme)
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的错误。你需要通过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"
}
{
“AzureAdB2C”:{
“实例”:https://.b2clogin.com",
“客户id”:“您的客户id”,
“域”:“您的租户域”,
“租户id”:“您的租户id”,
“SignupSigningPolicyId”:“您的策略名称”
}
请参考b2c中的.net核心web API@Hawkzey Azure AD、Azure AD B2B和Azure AD b2c访问令牌存储不共享内容。将前端切换到简单的Azure AD,或将后端切换到Azure AD b2c。后端的示例代码:@LukeDuda如果我想将用户投资到租户,并让他们能够登录到他说,如果不通过注册策略创建帐户,这将如何实现。
{
"AzureAdB2C": {
"Instance": "https://<your tenant name>.b2clogin.com",
"ClientId": " your client id",
"Domain": "your tenant domain",
"TenantId": "your tenant id",
"SignUpSignInPolicyId": "your policy name"
}