An eShopOnContainers error - "Sorry, there was an error: unauthorized_client"

August 18 · 3 mins read

“… When you face a tough problem in your work then you find a breakthrough, it’s probably something others will face. Blog about it.” - Vaughn Vernon

Are you getting this error when you click on the Login button of the eShopOnContainers project? Or when you click on the Authorize button of a swagger page in that project?:

Sorry, there was an error : unauthorized_client

Here’s what solved it for me:

Step 1: db

After running the application, open the SQL Server database (connect with SSMS to tcp:localhost,5433 with User Id=sa;Password=Pass@word;)

Then look at the ClientRedirectUris table in the Microsoft.eShopOnContainers.Service.IdentityDb database, using this script:

SELECT * FROM [Microsoft.eShopOnContainers.Service.IdentityDb].[dbo].[ClientRedirectUris]
Id RedirectUri ClientId
1 http://host.docker.internal:5109/swagger/oauth2-redirect.html 6
2 http://host.docker.internal:5110/swagger/oauth2-redirect.html 7
11 2
12 http://host.docker.internal:5104/ 1

Note the host.docker.internal in that table

Step 2: .env

Open the eShopOnContainers/src/.env file. You will see this in about line #7:

# Use this values to run the app locally in Windows

Change the into host.docker.internal like this:

# Use this values to run the app locally in Windows

Step 3: http://…:5100

Open the MVC Web app using http://host.docker.internal:5100/ instead of http://localhost:5100/

Then click on the Login button…