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.
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"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With