GithubHelp home page GithubHelp logo

dropbox-api's Introduction

Dropbox::API - Dropbox Ruby API client

A Ruby client for the Dropbox REST API.

Goal:

To deliver a more Rubyesque experience when using the Dropbox API.

Current state:

First release, whole API covered.

Important!!!

From version 0.2.0, Dropbox::API::File#delete and Dropbox::API::Dir#delete are gone!!

The reason is that it's based on Hashie::Mash and was screwing Hash#delete.

It is replaced with Dropbox::API::File#destroy and Dropbox::API::Dir#destroy.

Installation

Dropbox::API is available on RubyGems, so:

gem install dropbox-api

Or in your Gemfile:

gem "dropbox-api"

Configuration

In order to use this client, you need to have an app created on https://www.dropbox.com/developers/apps.

Once you have it, put this configuration somewhere in your code, before you start working with the client.

Dropbox::API::Config.app_key    = YOUR_APP_KEY
Dropbox::API::Config.app_secret = YOUR_APP_SECRET
Dropbox::API::Config.mode       = "sandbox" # if you have a single-directory app
# Dropbox::API::Config.mode       = "dropbox" # if your app has access to the whole dropbox

Dropbox::API::Client

The client is the base for all communication with the API and wraps around almost all calls available in the API.

Web-based Authorization

In order to create a Dropbox::API::Client object, you need to have the configuration set up for OAuth. Second thing you need is to have the user authorize your app using OAuth. Here's a short intro on how to do this:

consumer = Dropbox::API::OAuth.consumer(:authorize)
request_token = consumer.get_request_token
# Store the token and secret so after redirecting we have the same request token
session[:token] = request_token.token
session[:token_secret] = request_token.secret
request_token.authorize_url(:oauth_callback => 'http://yoursite.com/callback')
# Here the user goes to Dropbox, authorizes the app and is redirected
# This would be typically run in a Rails controller
hash = { oauth_token: session[:token], oauth_token_secret: session[:token_secret]}
request_token  = OAuth::RequestToken.from_hash(consumer, hash)
oauth_verifier = params[:oauth_verifier]
result = request_token.get_access_token(:oauth_verifier => oauth_verifier)

Now that you have the oauth token and secret, you can create a new instance of the Dropbox::API::Client, like this:

client = Dropbox::API::Client.new :token => result.token, :secret => result.secret

Rake-based authorization

Dropbox::API supplies you with a helper rake which will authorize a single client. This is useful for development and testing.

In order to have this rake available, put this on your Rakefile:

require "dropbox-api"
require "dropbox-api/tasks"
Dropbox::API::Tasks.install

You will notice that you have a new rake task - dropbox:authorize

When you call this Rake task, it will ask you to provide the app key and app secret. Afterwards it will present you with an authorize url on Dropbox.

Simply go to that url, authorize the app, then press enter in the console.

The rake task will output valid ruby code which you can use to create a client.

What differs this from the Dropbox Ruby SDK?

A few things:

  • It's using the ruby oauth gem, instead of reinventing the wheel and implementing OAuth communication
  • It treats files and directories as Ruby objects with appropriate classes, on which you can perform operations

Consider the following example which takes all files with names like 'test.txt' and copies them with a suffix '.old'

This is how it would look using the SDK:

# Because you need the session with the right access token, you need to create one instance per user
@session = DropboxSession.new(APP_TOKEN, APP_SECRET)
@session.set_access_token(ACCESS_TOKEN, ACCESS_SECRET)
@client = DropboxClient.new(@session, :app_folder)
# The result is a hash, so we need to call a method on the client, supplying the right key from the hash
@client.search('/', 'test.txt').each do |hash|
  @client.file_copy(hash['path'], hash['path'] + ".old")
end

With Dropbox::API, you can clean it up, first you put the app token and secret in a config or initializer file:

Dropbox::API::Config.app_key    = APP_TOKEN
Dropbox::API::Config.app_secret = APP_SECRET

And when you want to use it, just create a new client object with a specific access token and secret:

# The app token and secret are read from config, that's all you need to have a client ready for one user
@client = Dropbox::API::Client.new(:token  => ACCESS_TOKEN, :secret => ACCESS_SECRET)
# The file is a Dropbox::API::File object, so you can call methods on it!
@client.search('test.txt').each do |file|
  file.copy(file.path + ".old2")
end

What differs this from the dropbox gem?

Dropbox::API does not extend the Ruby primitives, like the dropbox gem:

https://github.com/RISCfuture/dropbox/tree/master/lib/dropbox/extensions

Dropbox::API::Client methods

Dropbox::API::Client#account

Returns a simple object with information about the account:

client.account # => #<Dropbox::API::Object>

For more info, see https://www.dropbox.com/developers/reference/api#account-info

Dropbox::API::Client#find

When provided a path, returns a single file or directory

client.find 'file.txt' # => #<Dropbox::API::File>

Dropbox::API::Client#destroy

Removes the file specified by path

Returns a Dropbox::API::File object of the deleted file

client.destroy 'file.txt' # => #<Dropbox::API::File>

Dropbox::API::Client#ls

When provided a path, returns a list of files or directories within that path

By default it's the root path:

client.ls # => [#<Dropbox::API::File>, #<Dropbox::API::Dir>]

But you can provide your own path:

client.ls 'somedir' # => [#<Dropbox::API::File>, #<Dropbox::API::Dir>]

Dropbox::API::Client#mkdir

Creates a new directory and returns a Dropbox::API::Dir object

client.mkdir 'new_dir' # => #<Dropbox::API::Dir>

Dropbox::API::Client#upload

Stores a file with a provided body under a provided name and returns a Dropbox::API::File object

client.upload 'file.txt', 'file body' # => #<Dropbox::API::File>

Dropbox::API::Client#chunked_upload

Stores a file from a File object under a provided name and returns a Dropbox::API::File object. It should be used for larger files.

client.chunked_upload 'file.txt', File.open('file.txt') # => #<Dropbox::API::File>

Dropbox::API::Client#download

Downloads a file with a provided name and returns it's content

client.download 'file.txt' # => 'file body'

Dropbox::API::Client#search

When provided a pattern, returns a list of files or directories within that path

By default it searches the root path:

client.search 'pattern' # => [#<Dropbox::API::File>, #<Dropbox::API::Dir>]

However, you can specify your own path:

client.search 'pattern', :path => 'somedir' # => [#<Dropbox::API::File>, #<Dropbox::API::Dir>]

Dropbox::API::Client#delta

Returns a cursor and a list of files that have changed since the cursor was generated.

delta = client.delta 'abc123'
delta.cursor # => 'def456'
delta.entries # => [#<Dropbox::API::File>, #<Dropbox::API::Dir>]

When called without a cursor, it returns all the files.

delta = client.delta 'abc123'
delta.cursor # => 'abc123'
delta.entries # => [#<Dropbox::API::File>, #<Dropbox::API::Dir>]

Optionally, you can set additional parameters, e.g. path_prefix. You can find all available parameters in the Dropbox API documentation.

delta = client.delta 'abc123', path_prefix: '/Path/To/My/Folder'
delta.cursor # => 'abc123'
delta.entries # => [#<Dropbox::API::File>, #<Dropbox::API::Dir>]

Dropbox::API::File and Dropbox::API::Dir methods

These methods are shared by Dropbox::API::File and Dropbox::API::Dir

Dropbox::API::File#copy | Dropbox::API::Dir#copy

Copies a file/directory to a new specified filename

file.copy 'newfilename.txt' # => #<Dropbox::API::File>

Dropbox::API::File#move | Dropbox::API::Dir#move

Moves a file/directory to a new specified filename

file.move 'newfilename.txt' # => #<Dropbox::API::File>

Dropbox::API::File#destroy | Dropbox::API::Dir#destroy

Deletes a file/directory

file.destroy 'newfilename.txt' # => #<Dropbox::API::File>

Dropbox::API::File methods

Dropbox::API::File#revisions

Returns an Array of Dropbox::API::File objects with appropriate rev attribute

For more info, see https://www.dropbox.com/developers/reference/api#revisions

Dropbox::API::File#restore

Restores a file to a specific revision

For more info, see https://www.dropbox.com/developers/reference/api#restore

Dropbox::API::File#share_url

Returns the link to a file page in Dropbox

For more info, see https://www.dropbox.com/developers/reference/api#shares

Dropbox::API::File#direct_url

Returns the link to a file in Dropbox

For more info, see https://www.dropbox.com/developers/reference/api#media

Dropbox::API::File#thumbnail

Returns the thumbnail for an image

For more info, see https://www.dropbox.com/developers/reference/api#thumbnail

Dropbox::API::File#download

Downloads a file and returns it's content

file.download # => 'file body'

Dropbox::API::Dir methods

Dropbox::API::Dir#ls

Returns a list of files or directorys within that directory

dir.ls # => [#<Dropbox::API::File>, #<Dropbox::API::Dir>]

Testing

In order to run tests, you need to have an application created and authorized. Put all tokens in spec/connection.yml and you're good to go.

Check out spec/connection.sample.yml for an example.

Releasing new version of gem

  1. Update version in lib/dropbox-api/version.rb and push to master
  2. Create new GitHub release with tag name starting with v and the version, for example v1.0.0
  3. Gem will be automatically built and pushed to rubygems.org with GitHub Action

Copyright and license

Copyright 2011 Zendesk

Licensed under the Apache License, Version 2.0

dropbox-api's People

Contributors

alvinlai avatar amalagaura avatar canadaduane avatar datapimp avatar dgb avatar docx avatar fedesoria avatar floere avatar jage avatar jjulian avatar jsierles avatar kenn avatar marvinscharle avatar mlc avatar patrickjs avatar petems avatar phaedryx avatar seangaffney avatar smcgivern avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dropbox-api's Issues

Optional asynchronous requests to Dropbox (Faraday + em-http-request)

How about using faraday with faraday_middleware instead of the oauth gem? This would allow people who want to make their application async to use em-http-request while letting the rest use the standard Net::HTTP adapter.

It's just a suggestion, but I'd like to know what you think about it before tinkering with it. Right now I've tried to replace TCPSocket but it's not a very elegant solution and I'm afraid it might get me in trouble later on.

A working example

Hey Everybody,

I was wondering if somebody could post some more example code.
My Ruby-fu isn't that great it hope somebody could help me out.

I want to create a Delayed Job that would upload files in the background with my Rails app.

I'll appreciate all the help I can get.

Thanks a lot in advance!

Remove git dependence in gemspec

Currently the gemspec has a dependency on git by using the git ls-files syntax.

We could switch it to use the Dir syntax which removes the dependence on git

License missing from gemspec

RubyGems.org doesn't report a license for your gem. This is because it is not specified in the gemspec of your last release.

via e.g.

spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']

Including a license in your gemspec is an easy way for rubygems.org and other tools to check how your gem is licensed. As you can imagine, scanning your repository for a LICENSE file or parsing the README, and then attempting to identify the license or licenses is much more difficult and more error prone. So, even for projects that already specify a license, including a license in your gemspec is a good practice. See, for example, how rubygems.org uses the gemspec to display the rails gem license.

There is even a License Finder gem to help companies/individuals ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough issue that even Bundler now generates gems with a default 'MIT' license.

I hope you'll consider specifying a license in your gemspec. If not, please just close the issue with a nice message. In either case, I'll follow up. Thanks for your time!

Appendix:

If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), GitHub has created a license picker tool. Code without a license specified defaults to 'All rights reserved'-- denying others all rights to use of the code.
Here's a list of the license names I've found and their frequencies

p.s. In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :). See the previous link or my blog post about this project for more information.

VCR Support in Specs

  • Refactor #42 so it's easier to setup
  • Make it so setup of files is idempotent so easy to re-run when re-running

Where does "oauth_token" come from, found in the README?

In the last line of the example code the local variable "oauth_token" is referenced. Here does "oauth_token" come from?

 consumer = Dropbox::API::OAuth.consumer(:authorize)
 request_token = consumer.get_request_token
 # Store the token and secret so after redirecting we have the same request token
 session[:token] = request_token.token
 session[:token_secret] = request_token.secret
 request_token.authorize_url(:oauth_callback => 'http://yoursite.com/callback')
 # Here the user goes to Dropbox, authorizes the app and is redirected
 hash = { oauth_token: session[:token], oauth_token_secret: session[:token_secret]}
 request_token  = OAuth::RequestToken.from_hash(consumer, hash)
 result = request_token.get_access_token(:oauth_verifier => oauth_token)

Dropbox::API::Error::Forbidden

Got this error while doing file upload. Used to work fine few days ago. Any clue what is wrong?

Error message:

Host: rpc.dropbox.com:443, FE: None, X-Dropbox-RequestId: None, X-Dropbox-App-Error: None, Invalid or missing signature

Timeout::Error

Hi
I am getting timeout error when uploading the image to dropbox.

  @client = Dropbox::API::Client.new(:token  => current_user.dropbox_token, :secret => current_user.dropbox_secret)
  data = File.read("demo.jpg")    
  @client.upload "demo.jpg", data

The error is

Completed 500 Internal Server Error in 59902ms

Timeout::Error (Timeout::Error):
 app/controllers/users_controller.rb:38:in `dropbox_download

The code at 38 number line is

 @client.upload "demo.jpg", data

But i am able to upload an image of 6Kb size and getting the error message for 254 Kb size file.

Dropbox::API::Raw request method > TypeError: can't convert Symbol into String

certain API methods (like client.ls, client.find etc) fail with TypeError:

fails here:

def request(endpoint, method, action, data = {})
    action.sub! ':root', data.delete(:root) if action.match ':root'
    action.sub! ':path', Dropbox::API::Util.escape(data.delete(:path)) if action.match ':path'

should be something like:

action.sub! ':root', Dropbox::API::Util.escape(data.delete(:root).to_s) if action.match ':root'
action.sub! ':path', Dropbox::API::Util.escape(data.delete(:path).to_s) if action.match ':path'

How to use auth token generated on Dropbox App Console

I'm trying to use dropbox with generated access token from Dropbox App Console.

If I execute:

curl https://api.dropbox.com/1/account/info -H "Authorization:Bearer <MY-ACCESS-TOKEN>"

request successfully returns my account info.

How can I use this access_token with 'dropbox-api'?

I tried (in Rails console):

Dropbox::API::Config.app_key = 'my_app_key'
Dropbox::API::Config.app_secret = 'my_app_secret'
Dropbox::API::Config.mode = 'dropbox'
client = Dropbox::API::Client.new(token: 'my_generated_access_token')
client.account

...and get: "Dropbox::API::Error::Unauthorized: 401 - Bad or expired token"

What am I missing?

client config with OAuth 2

with OAuth2, i only get back the token (not a token_secret).
How can i configure the client? because only with token it give me error.

client = Dropbox::API::Client.new(:token => session[:token])

Dropbox API v2

Just received notification that Dropbox API v1 will be turned off one year from now. What'd it take for this gem to work with API v2?

OAuth::Unauthorized (403 Forbidden)

def new
   consumer      = Dropbox::API::OAuth.consumer(:authorize)
   request_token = consumer.get_request_token
   @dropbox_auth = request_token.authorize_url(:oauth_callback => dropbox_callback_url)
end

callback:

def dropbox_callback
   consumer      = Dropbox::API::OAuth.consumer(:authorize)
   request_token = consumer.get_request_token
   request_token.get_access_token(:oauth_verifier => params[:oauth_token]) **here is the line where I am getting the error**

   client = Dropbox::API::Client.new :token => token, :secret => secret
end

App folder (sandbox) access attempt failed

For some reason I can't get the the client.ls command to use the mode I've set with Dropbox::API::Config.mode, it keeps returning the following error message:

1.9.2p290 :017 > client.ls
Dropbox::API::Error: App folder (sandbox) access attempt failed because this app is not configured to have an app folder.  Should your access type be 'dropbox' instead?
    from /Users/amotion/.rvm/gems/ruby-1.9.2-p290/gems/dropbox-api-0.2.0/lib/dropbox-api/connection/requests.rb:22:in `request'
    from /Users/amotion/.rvm/gems/ruby-1.9.2-p290/gems/dropbox-api-0.2.0/lib/dropbox-api/connection/requests.rb:41:in `get'
    from /Users/amotion/.rvm/gems/ruby-1.9.2-p290/gems/dropbox-api-0.2.0/lib/dropbox-api/client/raw.rb:26:in `request'
    from (eval):3:in `metadata'
    from /Users/amotion/.rvm/gems/ruby-1.9.2-p290/gems/dropbox-api-0.2.0/lib/dropbox-api/objects/dir.rb:9:in `ls'
    from /Users/amotion/.rvm/gems/ruby-1.9.2-p290/gems/dropbox-api-0.2.0/lib/dropbox-api/client.rb:25:in `ls'
    from (irb):17
    from /Users/amotion/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.0/lib/rails/commands/console.rb:47:in `start'
    from /Users/amotion/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.0/lib/rails/commands/console.rb:8:in `start'
    from /Users/amotion/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.0/lib/rails/commands.rb:41:in `'
    from script/rails:6:in `require'
    from script/rails:6:in `'

But when I check in the console it seems the mode is set correctly:

1.9.2p290 :016 > Dropbox::API::Config.mode
 => "dropbox" 

See anything obvious I might be missing?

#Delta scoped to path

It looks like path_prefix is one of the parameter to the official Dropbox delta api. But it's not implemented here. Also, when I'm using delta in console from current stable dropbox-api, the first time takes extremely long and I have to press ctrl-c to force kill it. Anyone has the same problem? Any plans to support the path scope? Thanks.

dropbox-api on rubygems?

It's that time of the night where I started playing around with the dropbox API and your dropbox gem.
The gemspec says it's named "dropbox-api" but it does not seem to be available on rubygems. But is this gem published?
Probably I'm missing something and tomorrow everything is fine but I'm opening this issue to pretend I have done at least anything tonight ;) - and to smile about tomorrow. :D
Anyway thanks for this nice gem!

Requests: Get Oauth Error instead of real error

I just tried moving a file to a path already present. Instead of getting the API error (A file with that name already exists at path...), I get a "Bad Oauth request".

From: /Users/jon/.rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/bundler/gems/dropbox-api-f62ac6348157/lib/dropbox-api/connection/requests.rb @ line 20 Dropbox::API::Connection::Requests#request:

    15:               raise Dropbox::API::Error::BadInput.new("400 - Bad input parameter - #{parsed['error']}")
    16:             when 401
    17:               raise Dropbox::API::Error::Unauthorized.new("401 - Bad or expired token")
    18:             when 403
    19:               parsed = MultiJson.decode(response.body)
 => 20:               raise Dropbox::API::Error::Forbidden.new('403 - Bad OAuth request')
    21:             when 404
    22:               raise Dropbox::API::Error::NotFound.new("404 - Not found")
    23:             when 405
    24:               parsed = MultiJson.decode(response.body)
    25:               raise Dropbox::API::Error::WrongMethod.new("405 - Request method not expected - #{parsed['error']}")

[9] pry(#<Dropbox::API::Connection>)> response.body
=> "{\"error\": \"A file with that name already exists at path ...\"}"

Add dir? to file

I can't differentiate easily between Dropbox::API::Dir and Dropbox::API::File, I'm interested in differentiate to put a different icon in the view, I'd like something like this.

@client.ls.each do |file|
  if file.dir?
    puts 'directory-icon' 
  else
    puts 'file-icon'
  end
end

I can work on this if it's a feature you'd like to add.

Dropbox::API::Error too generic

Hello,
500..599 http status responses raises Dropbox::API::Error which is a generic exception.

However there are certain codes, like 503 (https://www.dropbox.com/developers/reference/bestpractice see Rate Limiting) that are better to be raised separately along with the Retry-After header informations.

I keep hitting Dropbox::API::Error and I don't know what is it because nothing, expect the notification class, gets returned.

multi_json requirements too low

multi_json is at 1.10.x already and the requirements here for 1.7.x are a bit old. Is there a specific reason this can't be bumped higher or have a looser requirement? We're stuck on 0.4.2 till then or unless we monkey patch something into there. Thanks!

Path converted from absolute to relative

This is a question rather than a issue, but maybe an issue.

Why is the leading slash removed from the object path?

In dropbox-api/lib/dropbox-api/objects/fileops.rb at Dropbox::API::Fileops.path, line 22:

self['path'].sub(/^\//, '')

Maybe it's just because there're reasons I don't get to see, but in my particular experience this is causing confusion.

How to get directory hash returned from api?

if i do this:

dir = client.find("/myfolder")

it returns:

Dropbox::API::Dir bytes=0 hash="5cb18f46117da53473a2293d5de9f0fd" icon="folder" is_dir=true modified="Sat, 24 Aug 2013 21:33:03 +0000" path="/myfolder" rev="2137a255f" revision=2 root="app_folder" size="0 bytes" thumb_exists=false

But when i want to get the hash returned via

dir.hash

it seems to compute an own hash on the dir object. So, how can i access the hash returned from dropbox?

Thanks

undefined method `headers' for Net::HTTPServiceUnavailable

Error Message:

undefined method `headers' for #<Net::HTTPServiceUnavailable:0x00000005fd39c8>

Error Backtrace:

dropbox-api-0.4.2/lib/dropbox-api/connection/requests.rb:35:in `request'
dropbox-api-0.4.2/lib/dropbox-api/connection/requests.rb:52:in `get_raw'
dropbox-api-0.4.2/lib/dropbox-api/client/files.rb:12:in `download'

Chunked Download

Would be cool to have a chunked download option.

I'm working on a Curses Ruby app that you can download Dropbox files that uses dropbox-api, right now it's just silently downloading it in the background.

I might take a stab at this, @jsierles would be awesome if you could give me some guidance ๐Ÿ˜„

OAuth::Unauthorized Error

I have setup my rails app as documented.

I am testing the code in rails console and finding error:

consumer = Dropbox::API::OAuth.consumer(:authorize)
=> #<OAuth::Consumer:0x00007fba5fb340b8 @key="XXXXX", @secret="XXXX", @options={:signature_method=>"HMAC-SHA1", :request_token_path=>"/1/oauth/request_token", :authorize_path=>"/1/oauth/authorize", :access_token_path=>"/1/oauth/access_token", :proxy=>nil, :scheme=>:header, :http_method=>:post, :oauth_version=>"1.0", :site=>"https://www.dropbox.com"}>

request_token = consumer.get_request_token
OAuth::Unauthorized (400 Bad Request)

I am confused as I am following the README. Not sure about if I am making a mistake somewhere.

upgrading hashie dependency

I have checked out the gem, upgraded hashie to the ~> 3.4.0, and ran the tests. all is well.

is there any reason why this would be bad? i'll submit a pull and bump the version if your'e cool with it

Invalid or missing signature on upload

:-(

2013-06-10T21:18:41.250544+00:00 app[web.1]: Dropbox::API::Error::Forbidden - Invalid or missing signature:
2013-06-10T21:18:41.250544+00:00 app[web.1]:    /app/vendor/bundle/ruby/1.9.1/gems/dropbox-api-0.3.2/lib/dropbox-api/connection/requests.rb:55:in `put'
2013-06-10T21:18:41.250544+00:00 app[web.1]:    /app/vendor/bundle/ruby/1.9.1/gems/dropbox-api-0.3.2/lib/dropbox-api/connection/requests.rb:17:in `request'

Add Client#destroy method

So that files/directories can be deleted without retrieving their metadata. Most apps won't try deleting something that doesn't exist anyway and in such way we save 1 Dropbox request (and Dropbox requests are limited per app...)

Retrieve request_token in multiple controller actions + Rails

Hi,

I am using this gem to access the Dropbox API through a Rails app.
I am able to authorize the user by redirecting to Dropbox. However, my callback sends the user to a different action in the Controller. Here, I do not have access to the request_token (which I need to convert to an access token). I tried looking for various ways to pass the request_token between actions and serializing the token and storing it in the session was the only solution that I could find. I am not particularly fond of this solution because ideally, we should not be storing such stuff (especially serializing large objects) in the session.

Is there any other way to work around this ?
For e.g. in the Twitter+OAuth gem, you can store the token and the secret in the session and reconstruct the request_token in other actions?
Look at the callback action here
http://blog.brijeshshah.com/integrate-twitter-oauth-in-your-rails-application/
Is something similar exposed in this Dropbox gem?

Unauthroized on Dropbox::API::Client#account call

I followed the instructions under the Client section. OAuth works and i get a token and secret for the connected client. However, after trying to get account info, i get this error:

client = Dropbox::API::Client.new :token => token, :secret => secret
client.account
=> Dropbox::API::Error::Unauthorized

also happens with any other call (like #find, etc). any clue why that happens?

edit: added client.account line, missed that in the original post

Providing :path is not obvious about slashes.

If you provide

@client.search("pdf", :path => "/some/folder/on/dropbox")

You'll receive:

ERROR   Dropbox API Exception: #<Dropbox::API::Error::Forbidden: Invalid signature. Expected signature base string: GET%26https%3A%2F%2Fapi.dropbox.com%2F1%2Fsearch%2Fdropbox%2FPublic%26oauth_consumer_key%3Dasdasd%26oauth_nonce%3Dasdasd%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1333415769%26oauth_token%3Dasdasdoauth_version%3D1.0%26query%3Dpdf

As it double slashes the path:

~somwhere/dropbox-api-b9a5fef42299/lib/dropbox-api/connection/requests.rb:43:inget'`

path = "/search/dropbox//Public" # A kitten has been murder. Think of the kittens.

Should path.gsub(////, '') double slashes, as it would make the API friendlier? Or just note it the :path usage in the README

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.