Simple client library for Microsoft Skydrive API with OAuth2 authentication
Add this line to your application's Gemfile:
gem 'skydrive'
And then execute:
$ bundle
Or install it yourself as:
$ gem install skydrive
Skydrive uses OAuth2 authentication. First you will have to initialize a Skydrive::Oauth::Client object with the client id, client secret, callback url and scopes (explained here)
oauth_client = Skydrive::Oauth::Client.new("your_client_id", "your_client_secret", "http://yourcallbackurl", "wl.skydrive_update,wl.offline_access")
Obtain the authentication url
auth_url = oauth_client.authorize_url
Redirect the user to the above obtained auth_url. After user gives access to your app, they will be redirected to the callback url with a 'code' parameter. Extract this code and get the access token by invoking the following method
access_token = oauth_client.get_access_token("the_extracted_code")
If you have already stored the access_token details somewhere, you can instantiate the access token without having to authorize again. But this might require you to store the refresh token(if scope 'wl.offline_access' has been requested) as well.
access_token = oauth_client.get_access_token_from_hash("access_token", {:refresh_token => "refresh_token", :expires_at => 1234567})
After getting the access token instantiate the Skydrive client
client = Skydrive::Client.new(access_token)
To get the details about the acting user's home folder folder = client.my_skydrive
This returns a Skydrive::Folder object.
Please refer to the documentation for full details about the operations
- Every thing is an object. For eg: Skydrive::Folder, Skydrive::File
- I have introduced a new object Skydrive::Collection when the result contains multiple type objects
- Downloading files have been enabled
- File upload
- More specs
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request