Blog

Using Windows Live Contacts in Ruby1

You can use Windows Live SDK to get user contacts. To get start using this APIs you mush follow the following steps: 

  1. Register your application.

  2. Install and run the sample application for your platform.

  3. Request consent from the Windows Live ID user.

  4. Parse the consent token to obtain the delegation token.

  5. Use the delegation token to access an allowed offer and action. 

1.  Register your application: 

The first step is to register your application that will request contacts from Windows Live SDK. You will need to set the following application info:

  • Domain: your application domain.

  • Return URL: the url that Windows Live SDK will redirect to after authenticating user.

You will get a secret key to be used by your application. For more details check msdn.microsoft.com/en-us/library/cc287659.aspx

2.  Install and run the sample application for your platform:

If you are a ruby developer, you can use the following attached files:

  • windowslive_settings.rb

  • windowslivelogin.rb

  • DelAuth-Sample1.xml

3.  Request consent from the Windows Live ID user:

You will need to make an action that will request a consent from the API. You can get the url that will be called to get a consent by the following ruby code:

require 'windowslive_settings'

require 'cgi'

require 'windowslivelogin'

wll = WindowsLiveLogin.initFromXml(KEYFILE)

wll.setDebug(DEBUG)

consenturl = wll.getConsentUrl(OFFERS)

Open the url returned from consenturl. It will go to windows Live login page and ask for confirming to allow your application to get user contacts. The Windows Live user can accept or decline the request after signing into Windows Live. If the user accepts the request, then the consent is stored, and a consent token is returned to the calling third party (your application returnurl).

4.  Parse the consent token to obtain the delegation token:

After confirming, it will redirect to return_url in your application. This return_url will get lid and delegation token from the response. lid and delegation token will be used to get logged in user contacts. To parse the delegation token use the following code:

w = WindowsLive.new

token = w.delauth(params)

lid = token.locationid<

dt = token.delegationtoken 

5.  Use the delegation token to access an allowed offer and action:

Finally make request to get user contacts using lid and delegation token.

w = WindowsLive.new

contacts = w.get_contacts(lid, dt)

References:

msdn.microsoft.com/en-us/library/cc287637.aspx

  • 1 Comments

  • Blog_user_avatar Says:

    stady

Leave a Comment...