openIddict This server only accepts HTTPS requests (openIddict http无法获取token解决)

生产环境部署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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值