api - How should the options.authority be set when the api and the identity server are hosted on the same server
问题描述
I've got my web api (.net core web api) and my identity server 4 on the same IIS Windows Server. I've got the following code in my api with the authority set as below:
services.AddAuthentication("Bearer")
.AddJwtBearer("Bearer", options =>
{
options.Authority = https://identity.<domain name>.com;
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateAudience = false
};
});
I'm getting the following error when I communicate from my client to the api:
System.InvalidOperationException: IDX20803: Unable to obtain configuration from: 'https://identity..com/.well-known/openid-configuration'. ---> System.IO.IOException: IDX20804: Unable to retrieve document from: 'https://identity..com/.well-known/openid-configuration'. ---> System.Net.Http.HttpRequestException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ---> System.Net.Sockets.SocketException (10060): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
I believe the way I've set the Authority is causing the issue. Its trying to resolve itself to the same IP address and it times out. I've hosted my api on my development machine and called the same identity server and it works just fine. Should I make a change to the Hosts file or maybe find a base address (localhost or other) to resolve the communicate between the api and identity server?
解决方案
推荐阅读
- data-synchronization - 是否有任何文件属性表明特定文件已与云同步
- java - 杰克逊解析课不起作用
- c - (*prt)[N][N] 在处理堆分配内存时如何工作?
- ormlite-servicestack - ServiceStack OrmLite - 对 > 和 < 表达式使用字符串类型
- javascript - JavaScript 执行器在谷歌浏览器中工作,但在 Firefox 中不工作
- android - 在客户端显示来自服务器的多个数据源的分页数据
- android - ActivityManager.getCurrentUser() 在 Android O 中不可用
- git - git log 不显示提交的修改子模块
- dropwizard - 如何使用 dropwizard 指标进行异步回调
- operating-system - 分时系统也是多处理系统吗?