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 http://10.121.122.162:5105/xamarincallback 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
ESHOP_EXTERNAL_DNS_NAME_OR_IP=docker.for.win.localhost
ESHOP_STORAGE_CATALOG_URL=http://docker.for.win.localhost:5202/c/api/v1/…
ESHOP_STORAGE_MARKETING_URL=http://docker.for.win.localhost:5110/api/v1/…

Change the docker.for.win.localhost into host.docker.internal like this:

# Use this values to run the app locally in Windows
ESHOP_EXTERNAL_DNS_NAME_OR_IP=host.docker.internal
ESHOP_STORAGE_CATALOG_URL=http://host.docker.internal:5202/c/api/v1/…
ESHOP_STORAGE_MARKETING_URL=http://host.docker.internal:5110/api/v1/…

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…

Tada!!!