Steven Sinofsky, President, Windows and Windows Live Division at Microsoft, writes about using SkyDrive from within new Windows 8 Metro style apps. While apps get some amount of "automatic usage" of SkyDrive to roam settings, and the apps themselves roam, we know developers are anxious to make it easy for customers of their applications to have data they create roam easily across devices. SkyDrive is a great way to do this as every Windows Live ID has a free cloud-based drive.
This post authored by Mike Torres, the group program manager of the SkyDrive Devices and Roaming team, talks about how developers can build Metro style apps that use SkyDrive storage from within the apps.
He said in Windows 8, after the first time a user connects your app to their Live ID, the user will always have a seamless single sign-on experience from any Windows 8 PC where they're signed in with a Live ID. The same extends to your website, where they get a single sign-on experience if they're signed in to their PC with a Live ID or signed in to any site that supports Live ID, such as Hotmail or SkyDrive."
"The easiest way to use SSO with Live ID and integrate SkyDrive content into your Metro style app is to leverage the Live SDK," said Sinofsky. Adding, "This doesn't mean that your app needs to use any of these services--their use is entirely up to the developer. There's no requirement that apps for Windows 8 sign on with a Live ID or use any specific cloud-based storage. These're simply services available to app developers to use as they choose."
Using Windows Live ID in your Metro style app: To take advantage of SSO in your app, you'll need to place a sign-in button somewhere in the app. When the user clicks the sign-in button, they'll be automatically signed in if they're signed into their PC with a Live ID, otherwise, they'll be asked to sign in. After that the user is asked to provide consent to your app to access their data such as their SkyDrive photos. This workflow is handled automatically for you by simply adding the sign-in button. Notice that your customers still confirm sign-on to your application and are not automatically signed on--this is an important design consideration.
When the user clicks the sign-in button, they're asked to grant consent to allow your app to access their data. As noted earlier, if the user is signed into their PC with a Live ID, then SSO is in effect and the user doesn't have to sign in again. Instead they go directly to this consent screen. Once the user has granted access to their data to your app, OAuth 2.0 access tokens are returned to your app, and can then be used to make RESTful API calls against the Live cloud," explained Sinofsky.
Sinofsky noted "Integrating SSO and user data from SkyDrive into your app requires just a few lines of code with the Live SDK. Your app will be more personal and can take full advantage of a user's photos or documents in the cloud."
The full source code for the sample app is available here for download.
For more information about using the Live SDK to enable single sign-on in your apps and take advantage of the SkyDrive APIs, watch Dare Obasanjo's session "Power your app with Live services":
And, Steve Gordon's session "The complete developer's guide to the SkyDrive API from the BUILD conference":
You can also learn more by checking out http://dev.live.com and downloading the Live SDK Developer Preview.