【发布时间】:2020-07-16 02:23:26
【问题描述】:
我无法调用标有任一属性的任何方法:
[Authorize(AuthenticationSchemes = "Bearer")]
[Authorize]
我已经设置了 IdentityServer 项目,并且能够从项目中获取访问令牌。
web api 项目有以下配置设置:
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
var idserver = "https://ipaddressofidntityserver";
services.AddAuthentication("Bearer")
.AddJwtBearer("Bearer", options =>
{
options.Authority = idserver;
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateAudience = false
};
});
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
任何想法或帮助将不胜感激!
【问题讨论】:
-
你能包含一些堆栈跟踪吗?还是日志详细信息?
-
你的“ipaddressofidntityserver”是什么样的?只是IP地址或域名或本地主机? HTTPS 不适用于您的 IdentityServer 的 IP 地址。
标签: identityserver4