RISCfuture / dropbox

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

Net::HTTPUnauthorized #26

Closed stefanobernardi closed 13 years ago

stefanobernardi commented 13 years ago

My app was working and then suddenly I get this error:

HTTP status Net::HTTPUnauthorized received: http://api-content.dropbox.com/0/files/dropbox/MyFolder

on the upload metod.

my dropbox_session is in :dropbox mode (as you can see from the url) App status Production (Disable App) Access type Full Dropbox

RISCfuture commented 13 years ago

Your app was working? What changed when you suddenly started getting the error? Did you upgrade the gem or something?

stefanobernardi commented 13 years ago

Yup, I still have all the files I uploaded with it on my drop box, and my users too. It just stopped working. I did a push on heroku in which I changed the gemfile for another gem, so everything got reinstalled. I also probably did a bundle install locally. When did you push the latest gem version?

RISCfuture commented 13 years ago

The latest version of the gem (in the git repo) is not yet pushed to the gem server. Perhaps it will work for you? Also check the logs for your Gemfile.lock to see if you recently upgraded or downgraded the gem unexpectedly?

stefanobernardi commented 13 years ago

I didn't check the Gemfile.lock into my git repo. I'm not able to run the app with the gem installed from git, not sure why. gem "dropbox", :git => 'git://github.com/RISCfuture/dropbox.git' sb:appname sb$ bundle install Using dropbox (1.2.2) from git://github.com/RISCfuture/dropbox.git (at master) Your bundle is complete! sb:appname sb$ rake cron (in /Users/sb/Sites/savemyinbox) rake aborted! no such file to load -- dropbox

stefanobernardi commented 13 years ago

The weirdest thing is that with this app: https://github.com/stefanobernardi/sinatra-dropbox

it does work fine, and the code is mostly the same for the upload part.

My code:

  dropbox_session = Dropbox::Session.deserialize(user.dropbox_session)
  dropbox_session.mode = :dropbox
  if !dropbox_session.authorized?
    user.dropbox_session = nil
    user.dropbox_uid = nil
    user.dropbox_name = nil
    user.save
    puts user.email + "is unauthorized"
    Pony.mail(:to => user.email,
              :html_body =>  "<p>Hi there,</p><p>unfortunately the dropbox APIs suck hard. You need to reauthorize your dropbox account</p>",
              :body => "Please verify again your Dropbox credentials",
              :subject => "Problem with Dropbox account"
              )
  else
    dropbox_session.upload filepath, 'SaveMyInbox'

I have a puts on the filepath to my log to check that it is correct and it def is.

stefanobernardi commented 13 years ago

I did a major refactoring and it works now, still not sure what was wrong. Sorry and thanks for the prompt replies. Will send you a link to the app as soon as it's a bit more secure :)

RISCfuture commented 13 years ago

"Mysteries like these course like rivers through our Universe" :)