Create an MVC project, in the Startup.Auth.cs file, we can see some code like this:
650) this.width=650; "Width=" 604 "height=" 261 "title=" clip_image002 "style=" border:0px;padding-top:0px; Padding-right:0px;padding-left:0px;background-image:none, "alt=" clip_image002 "src=" http://images0.cnblogs.com/ Blog/139239/201505/190933497449060.png "border=" 0 "/>
This is actually Microsoft has helped us to achieve a good three-party login interface, we only need to create the corresponding developer account, and in which we configure some information related to our application, get the application ID and password, fill in the corresponding interface above, you can achieve the corresponding account of the three-party login.
First, Microsoft account three-party login introduction
Microsoft's developer account management address is: Https://account.live.com/developers/applications/index. Microsoft three-party login developer account configuration some instructions:
1, an application can only be a valid root domain name, and the root domain name cannot be localhost, the root domain will be automatically from your fill in the redirect URLs to determine the fill.
2. The redirect URL format used by the three-party login must be http://www.rootDomain.com/signin-microsoft. Where the HTTP protocol, root domain name, and port number are freely configurable, the latter/signin-microsoft is fixed.
Second, Google account three-party login introduction
Google's developer account management address is: Https://console.developers.google.com/project. Google three-party login developer account configuration some instructions:
1, to achieve Google three-party login, you must enable the Google + API, other required APIs can be added by themselves.
2, Google a client ID, you can configure multiple root domain different redirect URIs, and can be localhost.
3. The redirect URL format used by the three-party login must be http://www.rootDomain.com/signin-google. Where the HTTP protocol, root domain name, and port number are freely configurable, the latter/signin-google is fixed.
Third,
Office 365
Three-party login introduction
First of all, Microsoft has two sets of account system, a set called Microsoft account, is what we call Microsoft Accounts, the login address is: https://login.live.com/, or use the address https://www.outlook.com/ , automatic jumps are performed. Another set of "work" or School account is what we call Office 365, where the login address is: https://login.microsoftonline.com/, or use the address https:// outlook.office365.com/, automatic jumps are also performed.
Second, Microsoft does not provide us with a packaged office 3,653-party login interface, where we can use OpenID authentication to implement a three-party login for Office 365. The specific steps include the following points:
1, have a Office365 account, if not, you can apply for a 30-day free account, application address in:
Https://portal.office.com/Signup/Signup.aspx? Offerid=8368ac6a-5797-4859-b2ec-4d32330277c9&dl=o365_business&country=us&culture=en-us&ali=1#0.
2. Download Office Developer Tools for Visual Studio and install it because Office365 user data is placed on azure ad, so we need to register our application on Azure AD to get user data, This tool integrates with Visual Studio for easy registration of our applications: http://aka.ms/OfficeDevToolsForVS2013.
3. Use vs to create a Web application of the MVC framework, right click on the project, select "Properties", "Add", "Connected Service"
650) this.width=650; "Width=" 604 "height=" 566 "title=" clip_image004 "style=" border:0px;padding-top:0px; Padding-right:0px;padding-left:0px;background-image:none, "alt=" clip_image004 "src=" http://images0.cnblogs.com/ Blog/139239/201505/190933568696537.png "border=" 0 "/>
Then click on "Register your App", after successful login to your Office365 account, that is, the completion of the app registration work.
650) this.width=650; "Width=" 604 "height=" 351 "title=" clip_image006 "style=" border:0px;padding-top:0px; Padding-right:0px;padding-left:0px;background-image:none, "alt=" clip_image006 "src=" http://images0.cnblogs.com/ Blog/139239/201505/190933583382552.png "border=" 0 "/>
By clicking on the Web. config file, you will be able to see the ClientID and password information we obtained after registering successfully.
650) this.width=650; "Width=" 604 "height=" 142 "title=" clip_image008 "style=" border:0px;padding-top:0px; Padding-right:0px;padding-left:0px;background-image:none, "alt=" clip_image008 "src=" http://images0.cnblogs.com/ Blog/139239/201505/190933599471609.png "border=" 0 "/>
If you need to re-register the program, you only need to remove the Ida:clientid and Ida:password configuration items from the Web. config file, and then add the conencted service again, and you will be asked to register the program again.
4. On the Office 365 APIs Configuration page, select the appropriate service and click on the "Permissions" on the right to access the service as needed.
650) this.width=650; "Width=" 604 "height=" 351 "title=" clip_image010 "style=" border:0px;padding-top:0px; Padding-right:0px;padding-left:0px;background-image:none, "alt=" clip_image010 "src=" http://images0.cnblogs.com/ Blog/139239/201505/190934015418597.png "border=" 0 "/>
After the access setting is complete, you can see the following settings:
650) this.width=650; "Width=" 604 "height=" 351 "title=" clip_image012 "style=" border:0px;padding-top:0px; Padding-right:0px;padding-left:0px;background-image:none, "alt=" clip_image012 "src=" http://images0.cnblogs.com/ Blog/139239/201505/190934027444298.png "border=" 0 "/>
5. Click on the app properties on the Office 365 APIs Configuration page and we can set some of the app's attributes, including the name displayed after the app is registered, the scope of the app to be accessed, and the redirect URIs after successful authentication.
The redirect URIs only fills in our root domain and can register multiple different URI addresses.
650) this.width=650; "Width=" 604 "height=" 351 "title=" clip_image014 "style=" border:0px;padding-top:0px; Padding-right:0px;padding-left:0px;background-image:none, "alt=" clip_image014 "src=" http://images0.cnblogs.com/ Blog/139239/201505/190934040256555.png "border=" 0 "/>
6. Install Openidconnect-related components package install-package Microsoft.Owin.Security.OpenIdConnect.
7, write the code, the general content is as follows:
650) this.width=650; "Width=" 604 "height=" 313 "title=" clip_image016 "style=" border:0px;padding-top:0px; Padding-right:0px;padding-left:0px;background-image:none, "alt=" clip_image016 "src=" http://images0.cnblogs.com/ Blog/139239/201505/190934077443159.png "border=" 0 "/>
This article is from the "Grape City Control Technology Team Blog" blog, be sure to keep this source http://powertoolsteam.blog.51cto.com/2369428/1652661
Three-party logins in asp: Microsoft, Google, Office365