Skip to content
This repository has been archived by the owner on Sep 18, 2021. It is now read-only.

Issue with client credential flow. Possibly caching issue. #3852

Open
1 task done
jasonslemons opened this issue Sep 9, 2017 · 4 comments
Open
1 task done

Issue with client credential flow. Possibly caching issue. #3852

jasonslemons opened this issue Sep 9, 2017 · 4 comments
Labels

Comments

@jasonslemons
Copy link

jasonslemons commented Sep 9, 2017

  • I read and understood how to enable logging

Question / Issue

I'm using the console client credentials flow example and when I call the self host it works, but when i call my own id server it doesn't(i don't get a token response, and an exception is thrown in the logs). One possibly important difference between our id server and the self host example is that I save the client info to the db instead of it being in memory all the time . The client that is set up on my id server is:


    new Client
                {
                    ClientId = "ConsoleClient",
                    ClientName = "ConsoleClient",
                    Flow = Flows.ClientCredentials,
                    Enabled = true,
                    ClientSecrets = new List<Secret>
                    {
                        new Secret("F621F470-9731-4A25-80EF-888888888888".Sha256())
                    },
                    AllowedScopes = new List<string>
                    {
                        "ScopeAPI"
                    },
                    Claims = new List<Claim>
                    {
                        new Claim("location", "datacenter")
                    }
                }

and I'm calling it by

             var client = new TokenClient(
                Constants.TokenEndpoint,
                "ConsoleClient",
                "F621F470-9731-4A25-80EF-888888888888");

            return client.RequestClientCredentialsAsync("ScopeAPI").Result; 

The exception I get from the logs is below(and attached, since its hard to read), but the TokenResponse that gets returned is just 'Internal Server Error'. Fwiw, I have had the same kind of exception when authenticating with my mvc app and re publishing the id server project typically fixes it(in that case). Any ideas would be appreciated.

stacktraceAndError.txt

Relevant parts of the log file

Start token request
Secret id found: "ConsoleClient"
Unhandled exception accessing: /auth/core/connect/token

And the exception is

System.MissingMethodException: Method not found: 'System.Threading.Tasks.Task1<!!0> System.Data.Entity.QueryableExtensions.SingleOrDefaultAsync(System.Linq.IQueryable1<!!0>, System.Linq.Expressions.Expression1<System.Func2<!!0,Boolean>>)'. at
IdentityServer3.EntityFramework.ClientStore.d__2.MoveNext() at
System.Runtime.CompilerServices.AsyncTaskMethodBuilder1.Start[TStateMachine](TStateMachine& stateMachine) at IdentityServer3.EntityFramework.ClientStore.FindClientByIdAsync(String clientId) at IdentityServer3.Core.Services.Caching.CachingClientStore.<>c__DisplayClass1.<<FindClientByIdAsync>b__0>d__3.MoveNext() in c:\local\identity\server3\IdentityServer3\source\Core\Services\Caching\CachingClientStore.cs:line 0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at IdentityServer3.Core.Extensions.ICacheExtensions.<GetAsync>d__01.MoveNext() in c:\local\identity\server3\IdentityServer3\source\Core\Extensions\ICacheExtensions.cs:line 0
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at
IdentityServer3.Core.Services.Caching.CachingClientStore.d__6.MoveNext() in c:\local\identity\server3\IdentityServer3\source\Core\Services\Caching\CachingClientStore.cs:line 60
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at
IdentityServer3.Core.Validation.ClientSecretValidator.d__2.MoveNext() in c:\local\identity\server3\IdentityServer3\source\Core\Validation\ClientSecretValidator.cs:line 63
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at
IdentityServer3.Core.Endpoints.TokenEndpointController.d__7.MoveNext() in c:\local\identity\server3\IdentityServer3\source\Core\Endpoints\Connect\TokenEndpointController.cs:line 98
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at
IdentityServer3.Core.Endpoints.TokenEndpointController.d__0.MoveNext() in c:\local\identity\server3\IdentityServer3\source\Core\Endpoints\Connect\TokenEndpointController.cs:line 74
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at
System.Threading.Tasks.System.Web.Http910911.TaskHelpersExtensions.d__3`1.MoveNext() in c:\local\identity\server3\IdentityServer3\source\Core\Endpoints\Connect\DiscoveryEndpointController.cs:line 0
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at
System.Web.Http.Controllers.ApiControllerActionInvoker.d__0.MoveNext() in c:\local\identity\server3\IdentityServer3\source\Core\Endpoints\Connect\DiscoveryEndpointController.cs:line 0
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at
System.Web.Http.Filters.ActionFilterAttribute.d__5.MoveNext() in c:\local\identity\server3\IdentityServer3\source\Core\Endpoints\Connect\DiscoveryEndpointController.cs:line 0
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
System.Web.Http.Filters.ActionFilterAttribute.d__5.MoveNext() in c:\local\identity\server3\IdentityServer3\source\Core\Endpoints\Connect\DiscoveryEndpointController.cs:line 0
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at
System.Web.Http.Filters.ActionFilterAttribute.d__0.MoveNext() in c:\local\identity\server3\IdentityServer3\source\Core\Endpoints\Connect\DiscoveryEndpointController.cs:line 0
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at
System.Web.Http.Controllers.ActionFilterResult.d__2.MoveNext() in c:\local\identity\server3\IdentityServer3\source\Core\Endpoints\Connect\DiscoveryEndpointController.cs:line 0
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at
System.Web.Http.Filters.AuthorizationFilterAttribute.d__2.MoveNext() in c:\local\identity\server3\IdentityServer3\source\Core\Endpoints\Connect\DiscoveryEndpointController.cs:line 0
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at
System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext() in c:\local\identity\server3\IdentityServer3\source\Core\Endpoints\Connect\DiscoveryEndpointController.cs:line 0

Thanks,
--Jason

@brockallen
Copy link
Member

System.MissingMethodException: Method not found: 'System.Threading.Tasks.Task1<!!0> System.Data.Entity.QueryableExtensions.SingleOrDefaultAsync(System.Linq.IQueryable1<!!0>, System.Linq.Expressions.Expression1<System.Func2<!!0,Boolean>>)'. at

Sounds like some assembly version mismatch?

@jasonslemons
Copy link
Author

Could be, but threading is in mscorlib I think, and all of these projects are .net 4.5.2(perhaps it should be a lower version?) It seems to work much better if i take the client project out of a larger solution(that's under source control, fwiw) and put it in its own solution. I'm not sure there's much more I can say about symptoms or causes. I'm using vs 2015?

@jasonslemons
Copy link
Author

still an issue, using vs 2017 now. I tried grabbing a nuget package, 'system.threading.tasks' and that didn't seem to help.

@brockallen
Copy link
Member

brockallen commented Nov 4, 2017

I think this sounds the issue related to IdentityModel: IdentityModel/IdentityModel#70 (comment)

Can you confirm, and if so can we close?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants