RISCfuture / dropbox

An easy-to-use client library for the official Dropbox API.
MIT License
518 stars 46 forks source link

HTTPBadRequest when working with deserialized session #34

Closed andre-l-github closed 13 years ago

andre-l-github commented 13 years ago

using dropbox (current master, latest commit: c752471e7f6d829caba90961d8301aaf78b648c8) with:

Ruby 1.8.7 (2009-06-12 patchlevel 174) Rails 3.0.6

I get the following error when I use a deserialized session object for listing entries:

HTTP status Net::HTTPBadRequest received: http://api.dropbox.com/0/metadata/sandbox?list=true

My code handling the session initialization, serialization and deserialization looks like this:

  def dropbox_session
    if session[:dropbox_session]

      d_session = Dropbox::Session.deserialize(session[:dropbox_session])
      d_session.authorized! unless d_session.authorized?
      puts d_session.inspect
      d_session

    else

      d_session = Dropbox::Session.new('#########', '###########',
        {:authorizing_user => "###########", :authorizing_password => "#####"})
      d_session.mode = :dropbox
      d_session.authorize!
      session[:dropbox_session] = d_session.serialize
      d_session  

    end
  end

It works fine if I create new session every time I need.

Thanks for your help very much!

nanek commented 13 years ago

Note that the mode is not serialized. So it is defaulting back into sandbox mode, when you are likely trying to query dropbox mode. I agree this is an odd default, however it should help you get past this issue, by reseting the mode after deserialization.

RISCfuture commented 13 years ago

Oh, didn't notice; I can just serialize the mode.

RISCfuture commented 13 years ago

Should be fixed in e044f03b64e34f6d626d8396f2b41ef5483857c3, let me know.

RISCfuture commented 13 years ago

Closing this.