2016-11-05 13 views
1

私はIdSrv4からアクセストークンを取得し、私はそのトークンIdentityServer3.AccessTokenValidationのAPIとIdentityServer4

var client = new HttpClient(); 
client.SetBearerToken(token.AccessToken); 
var response = await client.GetAsync("http://localhost:60602/api/users"); 

と私のAPIを呼び出すしようとすると、私は、このエラーメッセージが表示されます。

Microsoft.Owin.Security.OAuth.OAuthBearerAuthenticationMiddleware Error: 0 : Authentication failed System.InvalidOperationException: Sequence contains no elements at System.Linq.Enumerable.First[TSource](IEnumerable 1 source) at IdentityServer3.AccessTokenValidation.DiscoveryDocumentIssuerSecurityTokenProvider.<RetrieveMetadata>b__1(JsonWebKey key) in c:\local\identity\server3\AccessTokenValidation\source\AccessTokenValidation\Plumbing\DiscoveryDocumentIssuerSecurityTokenProvider.cs:line 152 at System.Linq.Enumerable.WhereSelectListIterator 2.MoveNext() at System.IdentityModel.Tokens.JwtSecurityTokenHandler.ResolveIssuerSigningKey(String token, SecurityToken securityToken, SecurityKeyIdentifier keyIdentifier, TokenValidationParameters validationParameters) at System.IdentityModel.Tokens.JwtSecurityTokenHandler.ValidateSignature(String token, TokenValidationParameters validationParameters) at System.IdentityModel.Tokens.JwtSecurityTokenHandler.ValidateToken(String securityToken, TokenValidationParameters validationParameters, SecurityToken& validatedToken) at Microsoft.Owin.Security.Jwt.JwtFormat.Unprotect(String protectedText) at Microsoft.Owin.Security.OAuth.OAuthBearerAuthenticationHandler.d__0.MoveNext()

私が読んでこのコードで生成された証明書を追加してください。 https://github.com/ElemarJR/LearningIdentityServer4/tree/master/LearningIdentityServer.OAuth

ただし、成功しません。

WEBAPIコード ...

app.UseCookieAuthentication(new CookieAuthenticationOptions()); 
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); 
JwtSecurityTokenHandler.InboundClaimTypeMap.Clear(); 
app.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions 
{ 
     Authority = "http://localhost:5000",//Constants.BaseAddress, 
     RequiredScopes = new[] { "api1" }, 
}); 

...

任意の提案ですか?

+0

を見てみましょうするidentityserver3.accesstokenvalidationをアップグレードする必要がありますhttps://github.com/IdentityServer/IdentityServer3.AccessTokenValidation/issues/108解決策があるようです。 –

答えて

関連する問題