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

Viewed 17331

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

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();

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

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

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 !

Related