在进行微信公众号开发时,因为本地的服务是通过frp转发的,所以出现了identityServer认证失败,出现如下错误,
Failed to validate the token. Microsoft.IdentityModel.Tokens.SecurityTokenInvalidIssuerException: IDX10205: Issuer validation failed. Issuer: 'System.String'. Did not match: validationParameters.ValidIssuer: 'System.String' or validationParameters.ValidIssuers: 'System.String'. at Microsoft.IdentityModel.Tokens.Validators.ValidateIssuer(String issuer, SecurityToken securityToken, TokenValidationParameters validationParameters) at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateIssuer(String issuer, JwtSecurityToken jwtToken, TokenValidationParameters validationParameters) at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateTokenPayload(JwtSecurityToken jwtToken, TokenValidationParameters validationParameters) at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateToken(String token, TokenValidationParameters validationParameters, SecurityToken& validatedToken)
其实猛地一看错误是’System.String’ 木有头绪,但是看到 Issuer validation failed 我就想起了是反向代理导致的用户认证失败,查看 /.well-known/openid-configuration
后
将自己的token解析后
会发现iss 不一致,但是不知为何会报错 System.String
,但是我还是先设置options.TokenValidationParameters.ValidIssuers
,于是就正常了,也就没想太多了,abp代码如下