cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
We are making some updates so the Community might be down for a few hours on Monday the 11th of November. Apologies for the inconvenience and thank you for your patience. You can find out more here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to get token access into dropbox without it expiring (or copy .httr-oauth file)

How to get token access into dropbox without it expiring (or copy .httr-oauth file)

sydneyfr
New member | Level 2

I'd like to use dropbox as a remote storage center for some text files created by a deployed Shiny app. I need web users to be able to submit to a form which writes these files back to dropbox. In RStudio, I installed rdrop2, but I'm having trouble getting permanent remote access in the account which I set up for the storage. I ran 

token <- drop_auth()

saveRDS(token, file = "<savelocation>.rds")

and can find the token file on my computer. However all I did was add dtoken = token into my other code using the token from the global environment. Everything worked as expected until I tried to pick it up the next day again, by which I had lost authorization. Now when I try I'm getting: Warning: Error in drop_upload: Unauthorized (HTTP 401). I think this is because the token expired, but I don't understand how to get a refreshing token despite reading other posts here. I can't even authorize it anymore and get it to work like the first time. 

 

Another solution I heard of was copying the httr-oauth file into the working directory. Would this be a better idea? If so, how would I do it. 

 

Thanks!

 

 

2 Replies 2

Здравко
Legendary | Level 20

Hi @sydneyfr,

Long lived access token is deprecated already long time ago. In spite existing long lived tokens can still be used as such, all new issued access tokens are short lived! To keep long term access, you need to handle token refresh using refresh token. If you're using official SDK, refreshing gets internally, while if you use you own implementation take a look here, for instance.

Hope this gives direction.

Greg-DB
Dropbox Staff

@sydneyfr Ð—дравко is correct; Dropbox is now issuing short-lived access tokens (and optional refresh tokens) instead of long-lived access tokens. Short-lived access tokens expire after a short period of time, so you'd receive a 401 expired_access_token error when attempting to use a short-lived access token that has expired. You can find more information on this migration here.

Apps can still get long-term access by requesting "offline" access though, in which case the app receives a "refresh token" that can be used to retrieve new short-lived access tokens as needed, without further manual user intervention. You can find more information in the OAuth Guide and authorization documentation. There's a basic outline of processing this flow in this blog post which may serve as a useful example.

For reference, while the creation of new long-lived access tokens is now deprecated, we don't currently have a plan to disable existing long-lived access tokens. (If that changes, we will of course announce that ahead of time.) That being the case, you can continue using existing long-lived access token(s) without interruption, if you have any.

 

Dropbox can't offer support for RStudio/rdrop2/drop_auth in particular as those aren't made by Dropbox, so you may want to refer to the support resources and documentation for those for information on what functionality they support for this.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    Здравко Legendary | Level 20
What do Dropbox user levels mean?