Comments (3)
The problem is that invalid access tokens are definitely unexpected behavior. Theoretically a Dropbox access token should be good for a "long" period of time. Realistically, they go bad because of things like server hiccups or Memcached issues or whatever. When this happens, I think raising an exception is the appropriate thing to do, as it is an error state.
Authorization only happens once during the OAuth process. Once Dropbox::Session has the access token it does no more authorization. To check for a valid auth token would require the overhead of an additional API call, which is not something I'd like to do "automatically." My recommendation, if you want to write robust code that can handle invalid auth tokens, is to make a quick call to API#list (or some equally harmless method) when your app starts (or otherwise periodically) and just check for a 401.
I'm still ears though if you feel strongly about this and would like to make a further case.
from dropbox.
I see your point. However it's still a very common use case. By treating the state as unauthorized instead of an error, you can prevent every application from having to handle this case individually. Which is quite a gain, in my opinion.
Possible compromises would be a dedicated method to check for this case, or an option to disable the check (and thus the overhead).
For now, I'm using this:
# user de-authorized account - request re-authorization
begin
@dropbox.account
rescue Dropbox::UnsuccessfulResponseError
redirect_to oauth_authorize_path
return false
end
from dropbox.
Closing old tickets.
from dropbox.
Related Issues (20)
- ArgumentError: convert! has been removed. HOT 3
- 'No such file or directory' on session.upload HOT 2
- Minor error in README.rdoc example HOT 1
- Why is the length of the path limited to 255 characters? HOT 1
- HTTPBadRequest when working with deserialized session HOT 4
- Staying authorized HOT 1
- Allow setting the oauth token and secret manually? HOT 6
- Does Session.authorize! still work? HOT 4
- authorize! not working ? HOT 3
- An option to return hashes instead of structs HOT 2
- DropboxController::Filebox HOT 1
- Dropbox API v1 HOT 1
- Support for Dropbox API v1 HOT 1
- 401 Unauthorized HOT 10
- [feature] Support for delta and copy_ref HOT 5
- moving a file from iphone to my public folder
- upload issue
- Problem with the last version of Dropbox API (May 1st, 2013)
- Array#to_hash extension breaks one form of Kernel.exec and so prevents selenium-webdriver from working HOT 1
- 400 Bad Request (OAuth::Unauthorized) HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dropbox.