Skip to content

Instantly share code, notes, and snippets.

@frazelamont
Created September 2, 2017 13:35
Show Gist options
  • Save frazelamont/cfee30452deff2713e8b32b2e6dded9c to your computer and use it in GitHub Desktop.
Save frazelamont/cfee30452deff2713e8b32b2e6dded9c to your computer and use it in GitHub Desktop.
.netCore - use user secrets or app settings for google+ authentication
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// add facebook login, more too soon - changed in netcore v2
if (_isDevelopment)
{
services.AddAuthentication()
.AddGoogle(googleOptions =>
{
googleOptions.ClientId = Environment.GetEnvironmentVariable
("Authentication:Google:ClientId");
googleOptions.ClientSecret = Environment.GetEnvironmentVariable
("Authentication:Google:ClientSecret");
});
}
else
{
services.AddAuthentication()
.AddGoogle(googleOptions =>
{
googleOptions.ClientId = Configuration["Authentication:Google:ClientId"];
googleOptions.ClientSecret = Configuration["Authentication:Google:ClientSecret"];
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment