【发布时间】:2019-05-07 18:54:26
【问题描述】:
希望有人能指出正确的方向,我需要在我的 api 中验证身份服务器 4 发出的访问令牌。
API 中已设置授权属性。
访问令牌已从服务器正确检索,但在将访问令牌传递给请求时,我收到 401 Unauthorized 错误,并且没有任何处理请求被拒绝。我正在使用 IdentityServer3.AccessTokenValidation nuget 包。
我注意到对于 AccessTokenValidation 的 v4,您可以设置 RequireHttpsMetadata = false,但我不知道在 v3 中如何设置。
这是最好的方法还是我应该寻找另一个方向?
public void ConfigureAuth(IAppBuilder app)
{
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = "Cookies",
});
JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary<string,
string>
();
app.UseIdentityServerBearerTokenAuthentication
(new IdentityServerBearerTokenAuthenticationOptions
{
Authority = "http://localhost:5000",
RequiredScopes = new[] { "api2" },
});
}
谢谢
【问题讨论】:
-
你搞定了吗?
-
我有一篇关于nahidfa.com/posts/identityserver4-and-asp-.net-web-api 的帖子,其中包含完整的工作示例
标签: oauth-2.0 asp.net-web-api2 identityserver4 identityserver3