Library for communicating with Dropbox API v2.
Add this line to your application's Gemfile:
gem 'dropbox_api'
And then execute:
$ bundle
Or install it yourself as:
$ gem install dropbox_api
Dropbox uses OAuth, in order to use this library from your application you'll have to get an authorization code.
Once you have it, just pass it on client initialization:
DropboxApi::Client.new("VofXAX8D...")
#=> #<DropboxApi::Client ...>
Or set it as an ENV variable called DROPBOX_OAUTH_BEARER
, for example:
ENV["DROPBOX_OAUTH_BEARER"] = "VofXAX8D..."
DropboxApi::Client.new
#=> #<DropboxApi::Client ...>
The easiest way to obtain an access token is to get it from the Dropbox website. You just need to log in to Dropbox and refer to the developers section, go to My apps and select your application, you may need to create one if you haven't done so yet.
Under your application settings, find section OAuth 2. You'll find a button to generate an access token.
You can obtain an authorization code with this library:
require "dropbox_api/authenticator"
authenticator = DropboxApi::Authenticator.new(CLIENT_ID, CLIENT_SECRET)
authenticator.authorize_url #=> "https://www.dropbox.com/..."
- Open the authorization URL in your browser, authorize the application and copy your code.
auth_bearer = authenticator.get_token(CODE) #=> #<OAuth2::AccessToken ...>
auth_bearer.token #=> "VofXAX8D..."
. Keep this token!
Not implemented yet. :(
Once you've initialized a client, for example:
client = DropboxApi::Client.new("VofXAX8D...")
#=> #<DropboxApi::Client ...>
You can perform an API call like this:
result = client.list_folder "/sample_folder"
#=> #<DropboxApi::Results::ListFolderResult>
result.entries
#=> [#<DropboxApi::Metadata::Folder>, #<DropboxApi::Metadata::File>]
result.has_more?
#=> false
Refer to the documentation to see the details for each endpoint.
###Network adapter
This gem uses faraday. So it should work on any network library.
After checking out the repo, run bin/setup
to install dependencies. Then, run
bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To
release a new version, update the version number in version.rb
, and then run
bundle exec rake release
to create a git tag for the version, push git
commits and tags, and push the .gem
file to
rubygems.org.
Any help will be much appreciated. It should be quite easy to implement most of the endpoints that are still pending.
- Fork it ( https://github.com/Jesus/dropbox_api/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request