生产环境部署abp api 项目,其中用户登录授权方面使用了openIddict 模块
进行登录时使用发现获取token的接口无法正常返回数据,接口返回有如下提示: This server only accepts HTTPS requests
{
"error": "invalid_request",
"error_description": "This server only accepts HTTPS requests.",
"error_uri": "https://documentation.openiddict.com/errors/xxx"
}
大概的意思就是这个openIddict获取token的请求必须时https的,但是奇怪的是我域名确实是https访问的,只有nginx 配置反向代理时使用http。没办法只能去官网文档找不找看了。
随后我在Google上面找到了答案 https://github.com/openiddict/openiddict-core/issues/864
解决方案: https://github.com/openiddict/openiddict-core/issues/864#issuecomment-783432304
使用 DisableTransportSecurityRequirement()
解除https限制
在.net core里面这样配置
context.Services.AddOpenIddict()
.AddServer(option =>
{
option.AllowCustomFlow(GlobalConstant.OpeniddictGrantType_ThirdAuth);
option.SetTokenEndpointUris(new[] { "/api/ym/connect/token" });
option.UseAspNetCore().DisableTransportSecurityRequirement();
});
具体解析参考
https://github.com/openiddict/openiddict-core/issues/864
https://github.com/openiddict/openiddict-core/issues/864#issuecomment-783432304
【openiddict】翻译版本文档 https://www.aimzhi.cn/doc/openIddict.html