Website integration Windows Live ID Authentication

Source: Internet
Author: User

Running the C # QuickStart Sample

This topic explains how to install, run, and extend the QuickStart sample provided in the C # programming language.

Important:

The C # QuickStart sample is preconfigured to use default values for the application ID, secret key, and return URL parameters. the return URL is preconfigured to point to http: // localhost/webauth/sample/webauth-handler.aspx. for more information about how to customize these parameters, see Getting Your Application ID for Web Authentication.

Installing the Sample

When you install the sample, you put its files in the correct locations on your Web server. in this discussion, we assume that you have direct access to your Web server and that you develop and browse your site from the server.

Before you install the C # QuickStart sample, make sure that Microsoft Internet Information Services (IIS),. NET Framework 2.0, and ASP. NET are installed on your server. for IIS, make sure that:

  • A default Web site exists
  • The home directory of the default site is C: \ Inetpub \ wwwroot

To install the sample

  1. Run the C # sample installation file (webauth-cs-1.2.msi ).
  2. Copy the C: \ Program Files \ Windows Live ID \ WebAuth directory to C: \ Inetpub \ wwwroot.
  3. Create a directory named App_Code under C: \ Inetpub \ wwwroot, if it does not already exist.
  4. Move C: \ Inetpub \ wwwroot \ WebAuth \ App_Code \ WindowsLiveLogin. cs to the default App_Code directory at C: \ Inetpub \ wwwroot \ App_Code \.

The C # QuickStart sample is installed.

Running the Sample

After you install the sample, you can run it to see a demonstration of how Windows Live ID works.

To run the sample

  1. Go to http: // localhost/webauth/sample/default. aspx.
  2. Click Sign in. You are directed to the Windows Live ID sign-in page.
  3. Type your valid Windows Live ID and password to sign in. You are redirected to the sample application. The Sign in link has now changed to Sign out.
  4. Click Sign out. You are signed out.

 

References: http://msdn.microsoft.com/en-us/library/bb676630.aspx

 

First, like Google AuthSub, you must register your program on the Azure Services Developer Portal of Live's cloud computing Development Center.

 

After registration, you can start development. It should be noted that a very simple WindowsLiveLogin class is provided on the Live ID site. cs, you can get this class in this example: Running the C # QuickStart Sample, and it may be because of this class, microsoft does not need to provide any documents for interaction with the server (I did not find them). Therefore, I directly use this class without modifying any program. In this way, everything is much easier.

 

First, let's look at how to get the redirection address used for user login. This is too easy because it is the WindowsLiveLogin class method. It should be noted that the WindowsLiveLogin class has several methods to get the redirection address, the address obtained by the GetLoginUrl method is only used for user login, but does not apply for any permissions from the user. The GetConsentUrl (string scope) method can specify the permission to apply to the user for reading the corresponding data, like Google AuthSub, we also need to read the user's address book to obtain the user's Logon account address when using Live login. Therefore, we use wll. getConsentUrl ("Contacts. view "); method to get the Redirection URL, (" Contacts. view "indicates read-only access to the address book. before using this method, you must set the yyurl attribute (privacy declarative address) and ReturnUrl attribute (the revolving address after logon );

 

Note: before using the GetLoginUrl or GetConsentUrl method, Live requires that the user must have specified the PolicyUrl attribute of WindowsLiveLogin, that is, the address of the privacy statement, the specified website must be accessible. It seems that Live will also check whether the website can be accessed. In my system, I will designate the URL of the privacy statement as my login page, on that page, I have my statement about protecting user privacy.

 

After you move the user to the URL you just obtained, the user will be directed to the logon page of the Live ID:

 

 

Multiple parameters (delauth, login, logout, and clearcookie) are available when Live is switched back to the logon revolving address. These types should be implemented according to the requirements of the Live interface, each type has the following meanings:

 

1. delauth: This is my main type used. It is the type of rotation after the user logs on and grants the access permission. Note that this rotation can be obtained only when the GetConsentUrl method is called, the ConsentToken parameter can be obtained from the parameter, which is the data access token to be used later.

 

2. login, which is the type of rotation after the GetLoginUrl method is called. That is to say, it is the type of the parameter to be accessed without accessing any user data;

 

3. log out

 

4. clearcookie: Clear the Cookie

 

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.