-
Notifications
You must be signed in to change notification settings - Fork 462
Social Login Setup
In order to get social logins working , You need to first create applications and generate ids, secrets etc from respective social providers' website:
For more information on creating application and finding these secrets follow this link:
https://docs.microsoft.com/en-gb/aspnet/core/security/authentication/social/index
I have also provided a link to respective social provider's app creation page above their configuration in this file:
// https://console.developers.google.com/projectselector/apis/library?pli=1
.AddGoogle(options =>
{
options.ClientId = Startup.Configuration["Authentication:Google:ClientId"];
options.ClientSecret = Startup.Configuration["Authentication:Google:ClientSecret"];
})
.AddFacebook(options =>
{
options.AppId = Startup.Configuration["Authentication:Facebook:AppId"];
options.AppSecret = Startup.Configuration["Authentication:Facebook:AppSecret"];
})
// https://apps.twitter.com/
.AddTwitter(options =>
{
options.ConsumerKey = Startup.Configuration["Authentication:Twitter:ConsumerKey"];
options.ConsumerSecret = Startup.Configuration["Authentication:Twitter:ConsumerSecret"];
})
// https://apps.dev.microsoft.com/?mkt=en-us#/appList
.AddMicrosoftAccount(options =>
{
options.ClientId = Startup.Configuration["Authentication:Microsoft:ClientId"];
options.ClientSecret = Startup.Configuration["Authentication:Microsoft:ClientSecret"];
});
Once you have these ids/secrets for social providers, use them in appsettings.json file and replace hardcoded "ChangeMe" text. Here is the current config looks like:
"Authentication": {
"Google": {
"ClientId": "ChangeMe",
"ClientSecret": "ChangeMe"
},
"Facebook": {
"AppId": "ChangeMe",
"AppSecret": "ChangeMe"
},
"Microsoft": {
"ClientId": "ChangeMe",
"ClientSecret": "ChangeMe"
},
"Twitter": {
"ConsumerKey": "ChangeMe",
"ConsumerSecret": "ChangeMe"
},
"Github": {
"ClientId": "ChangeMe",
"ClientSecret": "ChangeMe"
},
"LinkedIn": {
"ClientId": "ChangeMe",
"ClientSecret": "ChangeMe"
}
Other social providers are added using external libraries. See csproj file for additional packages.
Note: When deploying in production make sure the host url in appsettings.json file correspond to your production host url.
Give it a try and if you have any propblem, raise an issue.