asp.net web api - IdentityServer3.AccessTokenValidation API and IdentityServer4 -


i access token idsrv4 , when try call api token

var client = new httpclient(); client.setbearertoken(token.accesstoken); var response = await client.getasync("http://localhost:60602/api/users"); 

i error message:

microsoft.owin.security.oauth.oauthbearerauthenticationmiddleware error: 0 : authentication failed system.invalidoperationexception: sequence contains no elements @ system.linq.enumerable.first[tsource](ienumerable1 source) @ identityserver3.accesstokenvalidation.discoverydocumentissuersecuritytokenprovider.<retrievemetadata>b__1(jsonwebkey key) in c:\local\identity\server3\accesstokenvalidation\source\accesstokenvalidation\plumbing\discoverydocumentissuersecuritytokenprovider.cs:line 152 @ system.linq.enumerable.whereselectlistiterator2.movenext() @ system.identitymodel.tokens.jwtsecuritytokenhandler.resolveissuersigningkey(string token, securitytoken securitytoken, securitykeyidentifier keyidentifier, tokenvalidationparameters validationparameters) @ system.identitymodel.tokens.jwtsecuritytokenhandler.validatesignature(string token, tokenvalidationparameters validationparameters) @ system.identitymodel.tokens.jwtsecuritytokenhandler.validatetoken(string securitytoken, tokenvalidationparameters validationparameters, securitytoken& validatedtoken) @ microsoft.owin.security.jwt.jwtformat.unprotect(string protectedtext) @ microsoft.owin.security.oauth.oauthbearerauthenticationhandler.d__0.movenext()

i read issue , add certificate generated code https://github.com/elemarjr/learningidentityserver4/tree/master/learningidentityserver.oauth

but without success.

webapi code ...

 app.usecookieauthentication(new cookieauthenticationoptions());  app.useexternalsignincookie(defaultauthenticationtypes.externalcookie);  jwtsecuritytokenhandler.inboundclaimtypemap.clear();  app.useidentityserverbearertokenauthentication(new identityserverbearertokenauthenticationoptions  {        authority = "http://localhost:5000",//constants.baseaddress,        requiredscopes = new[] { "api1" },  }); 

...

any suggestions ?

i had same problem; read following links [enter link description here][1]

identity server 4 token not validate in .netframework api use identity server 3

and

https://github.com/identityserver/identityserver3.accesstokenvalidation/issues/124

in teh summery must upgrade identityserver3.accesstokenvalidation " v2.13.0"


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -