gpt4 book ai didi

oauth-2.0 - Azure AD-B2C 错误 : IDX10501: Signature validation failed. 无法匹配 key : kid: '[PII is hidden]' , token : '[PII is hidden]'

转载 作者:行者123 更新时间:2023-12-04 14:50:34 26 4
gpt4 key购买 nike

我正在使用 Swagger 进行 API 调用,为了进行身份验证,我能够生成不记名 token ,但之后我收到 401 响应。检查日志后,错误如下:

Microsoft.IdentityModel.Tokens.SecurityTokenSignatureKeyNotFoundException: IDX10501: Signature validation failed. Unable to match keys: 
kid: '[PII is hidden]',
token: '[PII is hidden]'
我的 ConfigureAuth 方法如下:
private static void ConfigureAuth(IAppBuilder app)
{
var metadataEndpoint = string.Format(
configProvider.GetConfigValue<string>("ida:AadInstance", "AuthConfig"),
configProvider.GetConfigValue<string>("ida:Tenant", "AuthConfig"),
configProvider.GetConfigValue<string>("ida:SignInPolicy", "AuthConfig"));

string[] validAudiences = configProvider.GetConfigValue<string>("ida:Audiences", "AuthConfig").Split(',');
TokenValidationParameters tvps = new TokenValidationParameters
{
ValidAudiences = validAudiences,
AuthenticationType = configProvider.GetConfigValue<string>("ida:SignInPolicy", "AuthConfig"),
ValidateAudience = true,
ValidateIssuer = configProvider.GetConfigValue<bool>("validateIssuer", "AuthConfig"),
ValidateLifetime = true,
ValidAudience = configProvider.GetConfigValue<string>("Swagger:ClientId", "AuthConfig"),
//NameClaimType = "http://schemas.microsoft.com/identity/claims/objectidentifier",
};

//SecurityToken securityToken;
//JwtSecurityTokenHandler handler = new JwtSecurityTokenHandler();
app.UseOAuthBearerAuthentication(
new OAuthBearerAuthenticationOptions
{
AccessTokenFormat = new JwtFormat(tvps, new OpenIdConnectCachingSecurityTokenProvider(metadataEndpoint)),
Provider = new OAuthBearerAuthenticationProvider()
{
OnRequestToken = (context) =>
{
if (!string.IsNullOrEmpty(context.Token))
{
}

return Task.FromResult<int>(0);
},
OnValidateIdentity = (context) =>
{
////TO DO
//// Steps to perform after identity validation

return Task.FromResult<int>(0);
}
}
});
}

最佳答案

我不得不将我的 OpenIdConnectAuthenticationOptions.MetadataAddress 更新为
https://login.microsoftonline.com/tfp/ {tenantId}/{policyId}/v2.0/.well-known/openid-configuration。

关于oauth-2.0 - Azure AD-B2C 错误 : IDX10501: Signature validation failed. 无法匹配 key : kid: '[PII is hidden]' , token : '[PII is hidden]',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51221979/

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