Third-party logon in ASP. net mvc: Microsoft, Google, Office365, and mvcoffice365

Source: Internet
Author: User

Third-party logon in ASP. net mvc: Microsoft, Google, Office365, and mvcoffice365

Create an MVC project. In the Startup. Auth. cs file, we can see the following code:

This is actually the third-party login interface that Microsoft has implemented for us. We only need to create the corresponding developer account and configure some information related to our application, obtain the Application Id and password, and fill in the corresponding interface above to implement third-party login for the corresponding account.

 

1. Introduction to third-party logon with Microsoft account

The developer account management address of Microsoft is https://account.live.com/developers/applications/index. The following describes how to configure the third-party logon developer account of Microsoft:

1. An application can have only one valid root domain name, and the root domain name cannot be localhost. The root domain will be automatically filled with the Redirect URLs you entered.

2. The Redirect URL format used for third-party logon must be http://www.rootdomain.com/signin-microsoft. The HTTP protocol, root domain name, and port number can be configured freely, and the/signin-microsoft is fixed.

2. Introduction to third-party logon with a Google account

Google developer account management address: https://console.developers.google.com/project. Some instructions on the developer account configuration for Google third-party Logon:

1. To Enable third-party Google login, you must Enable Google + API. You can add other required APIS by yourself.

2. In a Client ID of Google, multiple Redirect URIs with different root domains can be configured and can be localhost.

3. The Redirect URL format used for third-party logon must be http://www.rootdomain.com/signin-google. The HTTP protocol, the root domain name, and the port number can be configured freely, and the/signin-google is fixed.

3. Introduction to third-party logon in Office 365

First of all, Microsoft has two sets of Account systems. One set is called Microsoft Account, which is our so-called Microsoft Account. The logon address is https://login.live.com/. you can use the address https://www.outlook.com/to automatically renew your Account. Another set is called Work or School Account, which is our so-called Office 365. The logon address is Login.

Secondly, Microsoft does not provide an encapsulated third-party logon interface for Office 365. here we can use OpenId authentication to implement third-party logon for Office 365. The specific steps include the following:

1. You have an Office365 account. If you do not have one, you can apply for a 30-day free account:

Https://portal.office.com/Signup/Signup.aspx? OfferId = 8347ac6a-5797-4859-b2ec-4d32330277c9 & dl = O365_BUSINESS & Country = US & culture = en-us & ali = 1 #0.

2. Download and install Office Developer Tools for Visual Studio. Because Office365 user data is stored on Azure AD, We need to register our application on Azure AD to obtain user data, this tool can be integrated with Visual Studio to register our application: http://aka.ms/officedevtoolsforvs2013.

3. Use VS to create a Web Application of the MVC Framework. Right-click the project and choose Properties, Add, and Connected Service"

Click "Register your app". After successfully logging on to your Office365 account, the App registration is completed.

Click the Web. config file to view the ClientID, Password, and other information we have obtained after successful registration.

To re-register the program, you only need to delete the ida: ClientID and ida: Password configuration items in the Web. config file, and then re-register the program when you Add the Conencted Service again.

4. On the Office 365 APIs configuration page, select the corresponding Service and click "Permissions" on the right to set the access Permissions for the Service as needed.

After the access permission settings are complete, you can see the related settings are roughly as follows:

5. Click App Properties on the Office 365 APIs configuration page. We can set some attributes of the App, including the name displayed after the App is registered, the accessible range of the App, and the Redirect URIs after successful authentication,

This Redirect URIs can be filled in only our root domain, and multiple different URI addresses can be registered at the same time.

6. Install the Install-Package Microsoft. Owin. Security. OpenIdConnect component Package related to OpenIdConnect.

7. Write the Code with the following content:

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.