last day (16 days later) » 

4:25 PM
1
Q: IdentityServer4: Failed to retrieve access token, An error was encountered while handling the remote login

PieterjanI'm trying to build a basic project using IdentityServer authentication. The past days I've been picking up bits and pieces from everywhere, but mostly from FullStackMarc. At the moment I'm able to get to the point where the Client-application requests a token from the IdentityServer. Then Identi...

 
IdentityServer will tell why it was reject in its log, do explore the log file. What does it say?
 
Thanks for the answer. Well I can't find a log file, but I'm only getting a non-related error in the console
 
you have to configure ASP.NET Core where to send the logs from ASP.NET Core and IdentityServer. Typically you use Serilog for that. You see it being configured in Program.cs in the IS4 templates, like here github.com/IdentityServer/IdentityServer4/blob/main/samples/‌​…
I typically send all my logs to Seq at datalust.co that is a logging solution created by the Serilog author
Are you sure you have created the PersistedGrants table?
 
No there is no PersistentGrants table created by efcore
I tried a last-resort and created the PersistentGrants table myself. The errors are now gone from the Output window, but the symptoms are still the same...
@ToreNestenius Thanks for the reply. I've added my Serilog output. All the calls seem to succeed
 
So, what is the current problem/issue?
 
4:32 PM
In my API project, I'm visiting the url to login into my IdentityProvider
This url returns the Challenge to my custom oauth provider
var props = signInManager.ConfigureExternalAuthenticationProperties(provider, redirectUrl);
return Challenge(props, provider);
All of this works fine. My custom login page from my IdentityServer project is shown, I can login and then I'm being redirected to the redirect-url specified by my oauth provider (/signin-my-auth-server)
So this is all in my consuming api project
But then I'm getting the following error:
Exception: Failed to retrieve access token.
Exception: An error was encountered while handling the remote login.
At the following line I can see the token being returned by the api-call
But somehow the consuming api (So the middleware that handles the redirect-url /signin-my-auth-server) throws the exception telling that it cannot read the token from the response
And I can see it, it's right there...
And also the request to get the userinfo is never processed, so AspNetCore.Identity doesn't even get this far, even without AuthorizeAttribute on the Account.Me method. It really seems to block at reading the token from the response in the image above
 
5:12 PM
ok, so you are using GitHub as an external provider, never tried with github, are you sure the token returned is a JWT token?
I would use a tool like telerik.com/download/fiddler to look at the request/response and examine and find exactly what response/request that is failing
but, I am a bit confused about what you do in account controller, why do you ask for a clientcredential token with grant type authorization code?
see the docs here
it should look like
var response = await client.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest
{
Address = "https://demo.identityserver.io/connect/token",

ClientId = "client",
ClientSecret = "secret",
Scope = "api1"
});
btw, if you have any friends who wants training in IdentitytServer, then I provide two classes here edument.se/en/search?q=identity
 
Thanks for the response
Let me take a look
 
hard to give good answers when you are just watching some random code :-)
but do look at the raw http traffic in fiddler
and alsso do look at the log files
 
Well the logfiles do not contain any errors
 
identtityServer would write something if you were to make an invalid request to it
try to lower the logging levels?
as a complemnt to logging ,you also have the events
 
6:03 PM
I succeeded in uploading my fiddler session to mintplayer.com/IdentityServerOAuth.zip
Change the extension to .saz and you should be able to open it with fiddler
 

  last day (16 days later) »