Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error The 'ClientId' option must be provided. When building a docker image

I've started a new .net core project and I configured it to use the Google+ Api for authentication. My Client Id and Secret are stored using dotnet user-secrets. When I build my docker image I get

 Unhandled Exception: System.ArgumentException: The 'ClientId' option must be provided.

I know this is because my secrets aren't being provided to the image. What I want to know is how can I provide my Id and Secret key without committing them to the repository and still run my image locally.

I was thinking when I deploy it to the server I can have them as part of the Env variables, I guess I could do that locally too, just wondering if anyone else has a solution for this that may be more elegant than mine.

I just can't find much info on how others are doing this.

like image 978
Woot Avatar asked Jan 08 '17 15:01

Woot


1 Answers

To Add Google+ Authentication you can see this guide.

Add this snippet in startup.cs

services.AddAuthentication().AddGoogle(googleOptions =>
{
    googleOptions.ClientId = Configuration["Authentication:Google:ClientId"];
    googleOptions.ClientSecret = Configuration["Authentication:Google:ClientSecret"];
});

Add this line in appsettings.json

"Authentication": {
    "Google": {
        "ClientId": "ID FROM GOOGLE API",
        "ClientSecret": "SECRET FROM GOOGLE API"
}
like image 196
Hassan Rahman Avatar answered Nov 11 '22 20:11

Hassan Rahman