Original tutorial
To create a web app using VS2015:
This tutorial uses a Facebook account to sign in, and you need to add the relevant classes to open NuGet:
Search Microsoft.AspNet.Authentication.Facebook and install:
Right-click on the project properties to turn on SSL:
In the Configure method of Startup.cs, add:
1 Apps. Usefacebookauthentication (options =2 {3 options. AppId = configuration["Authentication:Facebook:AppId"]; 4 Options. Appsecret = configuration["Authentication:Facebook:AppSecret"]; 5 });
Open Appsettings.json Edit Facebook's AppID and Appsecret, where the database is directly used by the local library, which is VS2015 comes with and does not need to install SQL Server:
authentication:facebook:appid, here is a authentication object that contains a Facebook object:
" Authentication " : { "Facebook": { "AppId" " xxxxxx " , " Appsecret " " xxxxxx " } }
Next sign up for Facebook apps:
Open https://developers.facebook.com/, login to your Facebook account, of course, there is a need for harmonious internet
Click Add New app:
Select website:
Select the Skip and Create App ID:
Fill in the name, email, select Category:
Click Settings:
To add an open platform:
Select website:
Here you need to fill in the callback address, this address is the HTTPS address above:
Copy the AppID and Appsecret into the Appsettings.json above:
Open the website, click Sign in, select Facebook login:
Will jump to the authorization page:
Then the error, because ASP.NET5 use EF to operate the database, at this time have not created a database, click Apply Migrations
Prompt Refresh page after success:
Jump to the registration page:
Sign in automatically after registration:
You can open SQL Server Object Explorer to view the database:
You will see that two records were inserted:
Similarly, you can sign in using Google Account:
Install Microsoft.AspNet.Authentication.Google:
Add the following code:
App. Usegoogleauthentication (options = options. ClientId= configuration["Authentication:Google:ClientId"]; Options. Clientsecret= configuration["Authentication:Google:ClientSecret"]; });
Configuration, add:
ASP.NET5 Sign in with Facebook