Saturday, August 7, 2010

How to connect to SkyDrive with WebDAV

Actually, I stumbled upon this when I decided to try out Office 2010 beta. I haven’t found any official documentation about how to connect to Windows Live SkyDrive with WebDAV (or any API), so I’m not sure how well supported this will be in the future. If you find any word about this from Microsoft, please let me know in the comments. The good news is that it works. The bad news is that it is very slow, but being 25 GB for free I guess you get what you pay for speed-wise (understandably).
[Update: New info about a tool I wrote to find out the addresses for WebDAV discussed below]
There is now a tool available that can determine the addresses you need for your WebDAV access to SkyDrive. It is available on CodePlex here. You can download the console application and run it from a command line. There is also a WPF application (seen below) if you have the latest version of .NET 3.5 SP1. More info in CodePlex site. But read the background below to know how I got there and what to do with the information that the tool provides.
Showing how to determine WebDAV address with WPF application
But let me start at the beginning with a brief introduction to Office 2010 beta. If you find this boring, scroll down to here.

Microsoft Office 2010 and installing the beta

I had actually decided to part from Microsoft Office in favor of more lightweight applications like Google Docs and OpenOffice. For two reasons: price and size. So I haven’t installed Office 2007 on any of my newer computers or laptops for the last six months or so in order to ensure that I don’t need it anymore and I have gotten by pretty well.
The application I’ve missed the most is probably Outlook. At the same time it is the application where the hate/love relationship is the greatest. I really like working with it but at the same time it feels way too big, bulky and complex for something that should be simple: mail and calendar (the way I see it). Too much MAPI baggage I think.
Then I listened to Windows Weekly with Paul Thurrott about a new installation option for Office 2010 beta. It is called Click-To-Run and sounded interesting since it uses an application virtualization technology called App-V that means that you can install and run the application side by side with whatever you have on your computer without risking changing any system settings (which especially affects Outlook, had I had Outlook 2007 installed).
I decided to give Office 2010 an extra chance and now I’m glad I did. Not only for discovering WebDAV access to SkyDrive. Everyone can download, install and use Office 2010 beta until october 2010 when it expires, but you do need a Windows Live ID.
Of course, there are a hundred-and-one SKUs (different packing of included applications etc) to choose from for Office 2010 also. No, I shouldn’t be so sarcastic about that since it does mean that if you don’t need everything in the full suite you will be able to get it for a lower price. But it is a pain to keep track of all the combinations.
What I’m getting to is that Click-To-Run only seems to be available for the “Home and Business” SKU, at least during the beta period. So go and download and install it here (requires registration via a Windows Live ID). The installation experience was smooth but a little weird. You see, Click-To-Run also has some sort of streaming built in so that different parts are downloaded when needed. In practice this meant that it looked as though only PowerPoint was installing since that was the screen shown during most of the installation. But I realized that was because an introductory PPT-file is automatically shown as the first thing after installation. Also, beware that one (or two?) dialogs didn’t activate as the topmost window and therefore I missed answering them (which is why the installation seemed to be stuck for a while).
One great thing about configuring Outlook 2010 that really impressed me was that I only had to specify my e-mail address for Outlook to figure out on which server my mail was located and by which access method it could connect. Maybe I shouldn’t be impressed since it usually is that easy for ordinary POP3/IMAP access, but still – a great improvement that has awakened my interest in Microsoft Office.
Another thing I like already is that the big circle button in the top left corner of the window is gone and has been replaced by a File tab (albeit a “special” tab) . That makes the interface much more uniform – a strip of tabs – and maybe even I can find the ribbon likable…

Microsoft Office 2010 and the web

The first thing that interested me, and that led to the discovery of WebDAV for SkyDrive was “Save to SkyDrive”. Yes I know – get to the point!! – not yet…
Paul Thurrott mentioned this feature in the netcast and it was the first thing I tried. Under the File tab and the Share menu option you’ll find “Save to SkyDrive”. Of course, I assume you already have a SkyDrive account so just login and you will be presented with your folders.
Office 2010 and Save to SkyDrive option
The next step in this screen dump is to double click the Public folder. Note however that this is really slow (for me, at least) and that Excel is unresponsive for a minute or two. Lets hope we can attribute this to beta software. Have patience, and you will (hopefully) be prompted with a dialog box to specify the file name, which is also what gave the WebDAV functionality away.
Dialog box asking for a file name
Also, before this dialog box appeared, the status bar gave away an address. I have removed the part that is unique to every user below (a guid), and changed it in the screen dump above.
Status bar in Office specifying the address
Nice! My conclusion was that Office 2010 must be using WebDAV for this so I had to investigate this further.
Another surprise was that SkyDrive in the browser will obviously support Office Web Applications, which means that you can view and even edit the documents right there in your favorite browser (which is Firefox, of course). At the moment, you can only view Word documents, but you can actually edit Excel spreadsheets. Excel editing looks really nice and is really hard to separate from the real application visually, however it does not seem to have a lot of functionality. I couldn’t find copy-down for instance. It remains to be seen just how much functionality will be available, but it would be strange if Microsoft didn’t try to at least match Google Docs Spreadsheets.

Steps to access SkyDrive folders with WebDAV in Windows Explorer

So, with this new information, here are the steps to connect to SkyDrive folders using WebDAV and get access to their contents in Windows Explorer. Note that I’m using Windows 7 (64-bit) and I don’t know if this works in older Windows versions.
[Update: I first thought that you could access SkyDrive folders without the sub domain mentioned above. That is probably not the case, so I've revised my instructions.]

In order to determine what path to specify in Windows when connecting via WebDAV, you either need to run my tool or use Office 2010. If using Office 2010, create a document and share it to SkyDrive as described above. When saving the document and specifying its file name, you have the chance to look at the address bar and copy the path, in my example:
https://pxeptc.docs.live.net/b8c6f2e973a17512/^2Public
Actually, the folder name “b8c6f2e973a17512″ in the path is the same as a personal sub domain when logging on to SkyDrive the normal way from your web browser. It can look like “http://cid-b8c6f2e973a17512.skydrive.live.com/”.
The sub domain “pxeptc” in my example is something derived from your SkyDrive account and the specific SkyDrive folder you want to access via WebDAV. So for every folder in SkyDrive that you want to access via WebDAV, you have to share a document from inside Office 2010 to determine this name.
In developing my tool, I saw that Office calls a web service to determine the WebDAV addresses for each folder in your SkyDrive account. That web service is located at http://docs.live.net/SkyDocsService.svc but you can’t access it in your browser since it requires a Live ID authentication token. (My tool fixes that.)
Also, some folders are special and “known” to the system much like “My Documents” on your computer. That means that their name is not the same as on the web page in SkyDrive. I have identified two such folders that I have. In SkyDrive they are called “Public” and “My Documents”, but in WebDAV they are called “^2Public” and “^2Documents”.
Also note that Windows recognize another way to specify this address which I think is interpreted in the same way. So the following two addresses would be equivalent:
https://pxeptc.docs.live.net/b8c6f2e973a17512/^2Public
\\pxeptc.docs.live.net@SSL\b8c6f2e973a17512\^2Public
To increase speed you should also make sure the following option is unchecked in Windows (if you don’t need it):
Control Panel, Internet Options, Connections, LAN Settings, Automatically detect settings

Conclusions

That’s it! Of course the maximum size of a single file is still enforced (I just had to try…). Unfortunately I don’t think this will work in other operating systems. I assume that the WebDAV part is used according to the standard, so that should not be a problem. However, I did notice when looking closer at the http communication that the server wants to authenticate with Passport1.4 (MS-PASS) which is Microsoft specific and I doubt that would work on Mac or Linux?
Also, it is very slow. Sure, you get what you pay for, but maybe there will be more (payment) options with SkyDrive in the future now that the sharing functionality from Office 2010 has been implemented. I don’t think I would mind paying if the speed was there.
I suspect Microsoft has something up their sleeve when it comes to “storage drives in the cloud” (duh! :) ). Right now they have been silent for quite some time. I use another service, namely Live Mesh, for file synchronization. It works great (5 GB limit), but it has been in beta for long now and Microsoft has discontinued all the developer stuff (sdks) for that service and for all or most of Live Services also I think. They are obviously up to something.
Unfortunately, there is no caching of files accessed over WebDAV. Windows has a built in system for remote access of files on remote locations called “Offline files”, but it only works on true Windows paths (SMB) and not WebDAV. At least not that I know of. Therefore you probably want to save to local disk and use a synchronization application to put your files on SkyDrive.
For me as a developer the most important part of this story is that there now is an api for SkyDrive access where there was none previously. Not counting the screenscraping way of the SkyDrive client library by ghollosy on Codeplex. It worked great when I tried it, but I don’t like to be in the hands of the web browser user interface on the site in case that changes (more of a “when”, than “if”?).

Additional information about photos

In my SkyDrive account I also have photos. They are obviously not exactly the same thing as a folder. I think they are somehow integreated with Windows Live Photos or whatever the branding is. Maybe you can have Windows Live Photos in your Windows Live account without having a SkyDrive folder account?
Anyway, I also discovered that this WebDAV access works with photos but I haven’t found a way to determine the sub domain needed for all my photo folders. However, if you have the name of a photo folder, I got Windows Explorer to do a redirect and tell me the name.
I just followed the pattern above and replaced the last part such as “^2Documents” with the exact name of one of my photo folders. And what do you know? Windows Explorer took a few seconds but then redirected to a sub domain under docs.live.net and there were all my photos in that folder!

How to set up WebDAV in Windows Explorer

If you need more specifics about how to create the WebDAV connection in Windows Explorer, here are the screendumps.
First, right-click on Network icon in Windows Explorer and select “Map network drive…”.
Select Map Network Drive in Windows Explorer
This dialog box will be shown:
Click on link
[Update: I previously had several screen dumps here, going through the whole wizard, but I later found out that as long as you map a drive letter at the same time, you can do it all from this single dialog box.]
Type in the path to the SkyDrive folder that you want access to in the “Folder” field. You can use either the https path or the \\ path. For instance:
\\pxeptc.docs.live.net@SSL\DavWWWRoot\b8c6f2e973a17512\^2Documents
Dialog box with filled in path
Windows will ask for your SkyDrive login either way, but you should also check the option “Connect using different credentials”. You don’t have to check “Reconnect at logon” of course, but then you have to remember the path the next time you need access. It may be a bit irritating to have the SkyDrive mapped on every boot since Windows probably will complain that it could not attach the mapped drive (if you don’t store the password permanently).
Click Finish and after typing your SkyDrive user name and password you are done.
Dialog box asking for user name and password
Showing the new drive in Explorer left pane
Remember that file access to a remote location using WebDAV probably is a lot slower than local file access in all cases, and especially slow on SkyDrive. Don’t be surprised if your waiting time increases when saving files etc. Source: http://www.mikeplate.com