Using SkyDrive in your Windows Phone applications: part 1

Introduction

In case you don’t know what is Skydrive, on Wikipedia you will find that “ Windows Live SkyDrive, initially called Windows Live Folders, is a free-of-charge file hosting service that allows users to upload files to a cloud storage and then access them from a Web browser.”

that was true before the BUILD. Now, Microsoft released an SDK that enables us to write  third party applications running on Windows 7, Windows Developer Preview and Windows Phone, that interact with the whole Live services, SkyDrive among them in different languages : JavaScript, C# and REST.

It also released its official Skydrive application for both Windows Phone and iOS.

Get Ready

First of all you have to download ans install the Live SDK v5.0 . You would probably need to use the Live Interactive SDK to explore the APIs and learn how to use them.

The Live Connect should recognize your application, that’s why you should go to Live Connect App Management site and create a new app.

create

You will get a Client ID and Client Secret that you will be using later with your application.

clientbis

Demo : Sign In

Let’s see how it works now:

Create a Windows Phone Application and make sure to add the following references:

references

You should also add the SignIn Button to your toolbox :

toolbox

In the main page, the user should sign in :

Main

 1: <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
 2:             <TextBlock Height="55" HorizontalAlignment="Left" Margin="54,113,0,0"
 3:                        Name="textBlock1" Text="Please sign in to access your Skydrive"
 4:                        VerticalAlignment="Top" Width="336" />
 5:             <my:SignInButton Content="Button" ClientId="Your_Client_ID"
 6:                              Scopes="wl.signin wl.basic " Branding="Windows" SessionChanged="signInButton1_SessionChanged"
 7:                              Height="72" HorizontalAlignment="Left" Margin="138,268,0,0"
 8:                              Name="signInButton1" VerticalAlignment="Top" Width="160" />
 9:             <TextBlock Height="32" HorizontalAlignment="Left" Margin="12,372,0,0" Name="infoTextBlock" Text=""
 10:                        VerticalAlignment="Top" Width="419" />
 11:
 12:         </Grid>

In the MainPage.xaml, I added a SingInButton control, You should put your own Client ID. I only used wl.signin and wl.basic scopes at this point.

wl.basic : Allows access to a user’s basic info, such as his or her Hotmail contact list.

wl.signin : Allows user’s log in .

The “infoTextBlock “ will indicate either the user is signed in or not. That will be handled in the C# code.

 1: private void signInButton1_SessionChanged(object sender, Microsoft.Live.Controls.LiveConnectSessionChangedEventArgs e)
 2:         {
 3:             if (e.Status == LiveConnectSessionStatus.Connected)
 4:             {
 5:                 session = e.Session;
 6:                 client = new LiveConnectClient(session);
 7:                 infoTextBlock.Text = "Signed in.";
 8:             }
 9:             else
 10:             {
 11:                 infoTextBlock.Text = "Not signed in.";
 12:                 client = null;
 13:             }
 14:
 15:         }

Run the application , hit the sign in button and you should get this screen:

sign in

Summary

In this first part, we grabbed the tools and SDK needed in order to use Skydrive in our Windows Phone applications.

Then we learnt how to sign in into Skydrive storage without writing any code.

In part two, we will learn how to read/insert files into Skydrive. Stay Tuned Sourire

About rabeb

Rabeb is a software engineer , fan of the latest .Net technologies, playing with Metro style applications for Win8 at work . In her spare time,she plays with Metro Style apps for Windows Phone.

Posted on January 7, 2012, in Mango, WP7 and tagged , . Bookmark the permalink. 3 Comments.

  1. Hy, can you post a link to download the project?

  2. how do I, way code, enter the name and password and login?

  1. Pingback: Using Skydrive in your Windows Phone applications: part2 « Diary of a .Net Fan …

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: