Export (0) Print
Expand All

Running the Visual Basic .NET Samples for Delegated Authentication

Cc742830.note(en-us,MSDN.10).gifNote:
This topic describes functionality that will be obsolete. This functionality is provided only to support legacy applications. Live Connect incorporates features that provide equivalent functionality.

This topic explains how to install, run, and extend the samples provided in the Visual Basic .NET programming language.

Cc742830.note(en-us,MSDN.10).gifImportant:
The Visual Basic .NET samples are preconfigured to use default values for the policy URL and return URL parameters. You must update these parameters before you can use the samples. For more information about how to update these parameters, see "Configuring the Samples" later in this topic.

When you install the samples, you put their 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.

  • Windows XP
    Before you install the Visual Basic .NET 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
  • Windows Vista
    Before you install the Visual Basic .NET sample, make sure that IIS and ASP.NET are enabled. If IIS or ASP.NET is disabled, perform the following steps before installing the samples:
    1. In Windows Vista, start Control Panel and then click Programs and Features.
    2. In the right pane, click Turn Windows features on or off. The Windows Features dialog box appears.
    3. Select the Internet Information Services check box.
    4. Double-click (or expand) World Wide Web Services, double-click Application Development Features, and then select the ASP.NET check box.
    5. Click OK to start the IIS and ASP.NET installation process.
    When the installation process is complete for IIS and ASP.NET, make sure that:
    • A default Web site exists
    • The home directory of the default site is C:\Inetpub\wwwroot

To install the samples

  1. Run the Visual Basic .NET sample installation file (delauth-vb-1.2.msi).
  2. Copy the C:\Program Files\Windows Live ID\DelAuth 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\DelAuth\App_Code\WindowsLiveLogin.vb to the default App_Code directory at C:\Inetpub\wwwroot\App_Code\.

The Visual Basic .NET samples are installed. The Visual Basic .NET library, named WindowsLiveLogin.vb, contains functions shared by both samples.

The samples require some configuration changes before you can run them. The following steps describe how to update the configuration files included with the samples.

To configure the samples

Cc742830.note(en-us,MSDN.10).gifImportant:
You must register your application with Microsoft before you run the samples, so that they can access the Windows Live ID service.
  1. Register your application and obtain a client ID. For more information about registering an application, see Getting Your Client ID for Delegated Authentication.
    Cc742830.note(en-us,MSDN.10).gifNote:
    You need both the secret key and the client ID, supplied to you after registration, to complete the configuration process for both samples.
  2. Use a text editor to open the web.config files, which are located in C:\Inetpub\wwwroot\delauth\sampleX, where X is the sample number.
  3. Change the value attribute for the add element with the key attribute set to wll_appid to match the client ID you received while registering the application. The following example illustrates the resulting element.
    <add key="wll_appid" value="0016000080000709"/>
    
  4. Change the value attribute for the add element with the key attribute set to wll_secret to match the secret key you specified while registering the application. The following example illustrates the resulting element.
    <add key="wll_secret" value="S!tr0ngPa55worD"/>
    
  5. For the first sample, change the value attribute for the add element with the key attribute set to wll_returnurl to match the return URL for the sample. The value for the first sample should be set to the following.
    <add key="wll_returnurl" value="http://<YourServerHostName>/delauth/sample1/delauth-handler.aspx"/>
    
    The second sample uses the return URL you specified when registering your application. You cannot override the return URL for the second sample.
  6. Change the value attribute for the add element with the key attribute set to wll_policyurl to match the privacy policy URL for the sample. The value for the first sample should be set to the following.
    <add key="wll_policyurl" value="http://<YourServerHostName>/delauth/sample1/policy.html"/>
    
    The value for the second sample should be set to the following.
    <add key="wll_policyurl" value="http://<YourServerHostName>/delauth/sample2/policy.html"/>
    
  7. Save and close the web.config files.

After you install the samples, you can run them to see a demonstration of how Windows Live ID Delegated Authentication works.

The first sample demonstrates how to use the GetConsentUrl, ProcessConsent, and ProcessConsentToken functions (included in the Visual Basic .NET library) to request, process, and parse a consent token from the Windows Live ID consent service.

To run the first sample

  1. Go to http://<YourServerHostName>/DelAuth/sample1/default.aspx.
  2. Click click here. You are redirected to the consent-request URL for the Windows Live ID consent service.
  3. If you have not yet signed in to the Windows Live ID service, you are redirected to the Windows Live ID sign-in page. Type your valid Windows Live ID and password to sign in, and then click Sign in.
  4. Select the actions to which you will allow access, and then click Allow Access.
  5. The Windows Live ID consent service attempts to retrieve a consent token and redirects you to the sample application's handler page.
  6. The sample application's handler page redirects you to the sample application's default page.
  7. If a consent token is successfully retrieved, the sample application's default page processes the consent token, stores it in a cookie, and displays the various elements contained within the consent token, as well as the entire consent token.
  8. Click here on the sample application's default page to delete the consent token. You are redirected to the consent application's handler page, where the cookie is expired.

The second sample demonstrates how to combine Web Authentication and Delegated Authentication functionality to sign in a Windows Live ID user; request, process, and parse a consent token from the Windows Live ID consent service; and then sign the user out.

Cc742830.note(en-us,MSDN.10).gifNote:
This sample uses a number of Visual Basic .NET library functions and handling techniques intended for Web Authentication purposes. For more information about those functions and techniques, see Using Web Authentication in the Windows Live ID Web Authentication SDK.

To run the second sample

  1. Go to http://<YourServerHostName>/DelAuth/sample2/default.aspx.
  2. If the text of the first link on the page is Sign in, click Sign in. You are redirected to the Windows Live ID sign-in page.
  3. Type your valid Windows Live ID and password to sign in, and then click Sign in. You are redirected to the sample application's default page. The Sign in link has now changed to Sign out and your user ID is displayed on the sample application's default page.
  4. Click click here. You are redirected to the consent-request URL for the Windows Live ID consent service.
  5. Select the actions to which you will allow access, and then click Allow Access.
  6. The Windows Live ID consent service attempts to retrieve a consent token and redirects you to the sample application's handler page.
  7. The sample application's handler page redirects you to the sample application's default page.
  8. If a consent token is successfully retrieved, the sample application's default page displays the various elements contained within the consent token, as well as the entire consent token.
  9. Click Sign out. You are signed out.

Now you're ready to explore ways to develop the sample code further to meet your site's needs.

The first sample requests access to a single, hard-coded permission. You could modify this permission to meet your needs, or replace the hard-coded permission with a text box to test access to the various offers and actions defined by a resource provider. The second sample builds on the first sample and provides a more complete example of integrating Web Authentication and Delegated Authentication together on your Web site.

Both samples focus on sending a single offer/action to a resource provider. You can extend these samples to handle multiple offer/actions. To accomplish this, separate each offer/action with a comma. For more information about how to build the consent request that sends these offer/actions, see Requesting Consent.

Look through the Visual Basic .NET library to see what additional functionality is available to you. The Visual Basic .NET library provides several functions that make it easier to integrate Web Authentication and Delegated Authentication into your Web site, and you can expand the library as needed to suit the requirements of your site.

Finally, you can share your discoveries and learn from others by participating in the Windows Live ID Development Forum.

Other Resources

Live Connect

Show:
© 2014 Microsoft