Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Identity Server 4 : Sorry, there was an error : unauthorized_client

I have set up identity server 4 to extent Umbraco so it uses a custom role provider.

Everything was working but now when I get redirected to my Identity server I get this error:

enter image description here

Can anybody shine some light on this error? I have tried rolling back my code in source control but nothing I do seems to help it. Is there anywhere I can see an error log?

Thanks, Scott

like image 523
Scott L Avatar asked Sep 04 '18 14:09

Scott L


3 Answers

The cause may be RedirectUris of a client do not include the actual redirect uri the client app is sending. This is configured in Client.cs method GetClients:

new Client
{
    ...
    RedirectUris = new[] { "https://..." }, 
    PostLogoutRedirectUris = new[] { "https://..." },
    AllowedCorsOrigins = new[] { "https://..." },
}

The redirect URI must match exactly the address the client is sending, including the HTTP scheme (http, https).

This can be found in log the file that lists allowed URIs and the actual URI of a failed authorization request. Identity server is using serilog, in program.cs it can be switched on in Main method:

...

Log.Logger = new LoggerConfiguration()
    .MinimumLevel.Debug()
    .MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
    .MinimumLevel.Override("System", LogEventLevel.Warning)
    .MinimumLevel.Override("Microsoft.AspNetCore.Authentication", LogEventLevel.Information)
    .Enrich.FromLogContext()
    .WriteTo.File("logs\\the-log-file-name.txt")
    .CreateLogger();

BuildWebHost(args).Run();
like image 68
Martin Staufcik Avatar answered Nov 10 '22 20:11

Martin Staufcik


I tried using https instead of http to access my local sitecore admin panel like this

https://site.local/sitecore and it worked remember its only https !

like image 40
Fahad Avatar answered Nov 10 '22 19:11

Fahad


I found out this was due to the RedirectUris being incorrect.

This error is thrown if there is anything wrong with the client.

like image 6
Scott L Avatar answered Nov 10 '22 18:11

Scott L