1

I am trying to use Dropbox for remote storage for a R shiny app. In the good old days you used to be able to get a long-lasting token via the rdrop2 package, but sadly that has not kept up with dropbox's migration to short-lived tokens and refresh tokens.

So, I am trying to get this done with the Oauth_ family of functions in the httr package.

I know that my dropbox auth URL needs to end up looking like: https://www.dropbox.com/oauth2/authorize?client_id=APP_KEY&token_access_type=offline&response_type=code

with the token_access_type=offline being the important bit for attaining the refresh token

my code, so far, looks like this:

dropbox_endpoint <- httr::oauth_endpoint(authorize = "https://www.dropbox.com/oauth2/authorize",
access = "https://api.dropbox.com/oauth2/token")

dropbox_app <- httr::oauth_app(appname="MY APP NAME", key = "APP_KEY", 
                                       secret = "SECRET")
dropbox_token <- httr::oauth2.0_token(endpoint=dropbox_endpoint, app=dropbox_app, 
                                              cache = TRUE)

Where in this code do I put token_access_type=offline ?? I have tried a few options, but I am now just driving myself insane...

1 Answers1

0

Ok, so borrowing from this post here How to specify user_params within httr::oauth2.0_token to obtain refresh token?

query_authorize_extra = list(token_access_type= "offline") seems to be the ticket...I mean token

This goes in the httr::oauth2.0_token() function like so:

dropbox_token <- httr::oauth2.0_token(endpoint=dropbox_endpoint, app=dropbox_app,cache = TRUE,
query_authorize_extra = list(token_access_type= "offline"))