Asp.net web api 带有OAuthBeareTokens和WindowsAzureActiveDirectoryBearer的Web API
我正在开发一个API,它有多种方式来授权/验证用户。目前,我为Azure Activie目录添加了支持。但是,默认的OAuth承载令牌和Azure广告似乎不能很好地协同工作。问题在于,每次用户使用OAuth承载令牌时,Azure AD使用的JwtSecurityTokenHandler就会抛出异常 中发生“System.ArgumentException”类型的异常 System.IdentityModel.Tokens.Jwt.dll,但未在用户代码中处理 其他信息:IDX10708: “System.IdentityModel.Tokens.JwtSecurityTokenHandler”无法读取此内容 字符串:。。。字符串需要采用紧凑的JSON格式,这是 表格: 验证设置:Asp.net web api 带有OAuthBeareTokens和WindowsAzureActiveDirectoryBearer的Web API,asp.net-web-api,oauth,asp.net-identity,owin,adal,Asp.net Web Api,Oauth,Asp.net Identity,Owin,Adal,我正在开发一个API,它有多种方式来授权/验证用户。目前,我为Azure Activie目录添加了支持。但是,默认的OAuth承载令牌和Azure广告似乎不能很好地协同工作。问题在于,每次用户使用OAuth承载令牌时,Azure AD使用的JwtSecurityTokenHandler就会抛出异常 中发生“System.ArgumentException”类型的异常 System.IdentityModel.Tokens.Jwt.dll,但未在用户代码中处理 其他信息:IDX10708: “Sy
public void ConfigureAuth(IAppBuilder app)
{
var builder = new ContainerBuilder();
app.UseAutofacMiddleware();
app.UseOAuthBearerTokens(new OAuthAuthorizationServerOptions
{
TokenEndpointPath = new PathString("/token"),
RefreshTokenProvider = new RefreshTokenProvider(),
Provider = new ApplicationOAuthProvider(),
AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
AccessTokenExpireTimeSpan = TimeSpan.FromHours(1),
AllowInsecureHttp = true,
});
app.UseWindowsAzureActiveDirectoryBearerAuthentication(new WindowsAzureActiveDirectoryBearerAuthenticationOptions
{
TokenValidationParameters = new TokenValidationParameters
{
ValidAudience = ConfigurationManager.AppSettings["ida:Audience"]
},
Tenant = ConfigurationManager.AppSettings["ida:Tenant"],
Provider = new Office365OAuthProvider()
});
}
在使用OAuth令牌时,如何停止API以针对Azure AD对用户进行身份验证