cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to know what we learned at IBC? Check out our learnings on media, remote working and more right 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 a refresh token

How to get a refresh token

oen124
New member | Level 2
Go to solution

I have an app written in Python to upload files which I set up in the www.dropbox.com/developers/apps section. I generated an access token and chose the expiration to be "No Expiration". When I run it manually with "python app_name.py" it works. But when I setup a cron job (with the same python interpreter etc.) I receive the error:

 

raise BadInputException('OAuth2 access token or refresh token must be set')
  dropbox.dropbox_client.BadInputException: OAuth2 access token or refresh token must be set

 

 

I tried to look for instructions about how to get this refresher token but didn't find anything. What's going on? How it works when I do it manually? Please assist.

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

If you're using a long-lived access token (e.g., as you described, by setting the "Access token expiration" setting in the App Console to "No Expiration" and then using the "Generate" button to generate an access token for your account and app), then you don't also need a refresh token. (Refresh tokens are for use with short-lived access tokens, not long-lived access tokens. Please note that long-lived access tokens are considered deprecated though. )

 

The particular error you're getting here is indicating that you did not pass a non-empty value for either the oauth2_access_token parameter (for a long-lived or short-lived access token) or oauth2_refresh_token (for a refresh token) when building your client. At least one of these parameters is needed to make API calls.

 

How are you passing your access token in and constructing that Dropbox object? It sounds like something about your environment isn't successfully retrieving your access token when running from the cron job.

View solution in original post

3 Replies 3

Greg-DB
Dropbox Staff
Go to solution

If you're using a long-lived access token (e.g., as you described, by setting the "Access token expiration" setting in the App Console to "No Expiration" and then using the "Generate" button to generate an access token for your account and app), then you don't also need a refresh token. (Refresh tokens are for use with short-lived access tokens, not long-lived access tokens. Please note that long-lived access tokens are considered deprecated though. )

 

The particular error you're getting here is indicating that you did not pass a non-empty value for either the oauth2_access_token parameter (for a long-lived or short-lived access token) or oauth2_refresh_token (for a refresh token) when building your client. At least one of these parameters is needed to make API calls.

 

How are you passing your access token in and constructing that Dropbox object? It sounds like something about your environment isn't successfully retrieving your access token when running from the cron job.

oen124
New member | Level 2
Go to solution

Thanks,

Yeah my problem was that I did not specify the line correctly in crontab, I had to source my profile file in order for the env vars to be seen by the cron job. Thanks a lot.

 

You said that long lived tokens are deprecated, does that mean it won't be available soon?

 

p.s - you have a bug here in the forums, each time I refresh the page it adds +1 to the views count of the message 🙂

Greg-DB
Dropbox Staff
Go to solution

Long-lived access tokens are now considered deprecated, but 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).

 

Note though that after the change you won't be able to create new long-lived access tokens.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    oen124 New member | Level 2
What do Dropbox user levels mean?