Three-party logins in asp: Microsoft, Google, Office365

Source: Internet
Author: User

Create an MVC project, in the Startup.Auth.cs file, we can see some code like this:

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"

Then click on "Register your App", after successful login to your Office365 account, that is, the completion of the app registration work.

By clicking on the Web. config file, you will be able to see the ClientID and password information we obtained after registering successfully.

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.

After the access setting is complete, you can see the following settings:

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.

6. Install Openidconnect-related components package install-package Microsoft.Owin.Security.OpenIdConnect.

7, write the code, the general content is as follows:

Three-party logins in asp: Microsoft, Google, Office365

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.