Skydrive integration with AzureCopy.

AzureCopy has been making good headway of late. I now have support for Azure Blob Storage, Amazon S3, local filesystem and now SkyDrive! Integration is not complete but the core two pieces of functionality (read blobs, write blobs) are now working.

I’ve release version 0.7.0.1 which has all the new bits.

The one “klunky” bit of Skydrive integration with a console app is the OAuth authentication. For this, the user needs to load up the Skydrive login page with a redirection url that points to my domain. With the resulting URL you copy/paste an element to the AzureCopy config file and away you go.

 

Things I have learned:

 

1) SkyDrive API is quite nice, but it gives you the basic building blocks. Anything more complex you need to write yourself. (yes, I’m looking at you Mr traversing subdirectories!!)

2) The basics of OAuth (code, access token, refresh token, client secrets etc) are finally sticking in my head. Never thought that would happen.

 

As usual, the code is here and the binary is here

Skydrive, OAuth and Live account hell.

I’ve started to try and integrate Skydrive access into AzureCopy and have learned a number of important lessons, mainly around OAuth. I’ve often dabbled in OAuth, partially knowing what I’m doing, partially copying examples and partially good luck.

AzureCopy is a command line tool, but performing the “OAuth Dance” seems to always require a browser. This browser step should only ever be required to get the refresh token (well strictly speaking the “code” which can be used to get the refresh token). Until I figure out how to get command line apps to work properly with OAuth I’m going to leave this in a semi-completed state.

For now, I’ll be leaving Skydrive integration in “extreme beta” which means you have to know what you’re doing and get your refresh token manually.  The steps to do so are:

1) Load URL:

https://login.live.com/oauth20_authorize.srf?client_id=00000000480EE365&scope=wl.offline_access&response_type=code&redirect_uri=http://kpfaulkner.com

2) Log in with your live id (microsoft account) and it should return a url similar to:

http://kpfaulkner.com/?code=75a26998-356f-c1c0-3ae1-12345

3) Copy the value of the code parameter and paste into the azurecopy.exe.config entry in the “SkyDriveCode” tag.

4) Use AzureCopy via command line as usual, now you’ll be able to use skydrive for source/destination.

AzureCopy will then retrieve a RefreshToken from SkyDrive and request fresh AccessTokens per session. Currently this is source only and not in any released binaries, but is definitely moving along. Once I’ve finished this I think I’ll target RackSpace or DropBox…