cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Share your feedback on the Document Scanning Experience in the Dropbox App 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: 

Re: Tokens only valid for 4 hours from app console

Re: Tokens only valid for 4 hours from app console

ogurchik222
Explorer | Level 4
Go to solution

Hi, I am going to install Python Software on Linux server with no access to browser. Can you please tell me, can I automatically generate short-lived tokens to access Python Dropbox SDK without browser actions? If yes, can you please send me a link to a code snippet (WITH NO BROWSER ACTIONS) I can use only requests and your API. 

1 Accepted Solution

Accepted Solutions

Здравко
Legendary | Level 20
Go to solution

Hi @ogurchik222,

Unfortunately, in Dropbox Python SDK examples is not any like you are looking for. I have posted some time ago some code (not exactly what you ask for) which do the authentication flow (on first run) and actual work in the same module. You can split this code and use the part responsible for authentication flow on machine with browser (just a single call) and the other part on your browserless server. :winking_face: The configuration file, once created, can be copied in a way convenient for you on the same/equivalent place. I believe this example gives a way you can use in your Python Software.

Good luck.

View solution in original post

3 Replies 3

Здравко
Legendary | Level 20
Go to solution

Hi @ogurchik222,

Unfortunately, in Dropbox Python SDK examples is not any like you are looking for. I have posted some time ago some code (not exactly what you ask for) which do the authentication flow (on first run) and actual work in the same module. You can split this code and use the part responsible for authentication flow on machine with browser (just a single call) and the other part on your browserless server. :winking_face: The configuration file, once created, can be copied in a way convenient for you on the same/equivalent place. I believe this example gives a way you can use in your Python Software.

Good luck.

Greg-DB
Dropbox Staff
Go to solution

@ogurchik222 As Здравко indicated, it is not possible to fully automate the OAuth process where the user chooses to authorize the app and the app then receives the resulting access token and optional refresh token. This needs to be done manually by the user at least once. If your app needs to maintain long-term access without the user manually re-authorizing it repeatedly, the app should request "offline" access so that it gets a refresh token. The refresh token doesn't expire and can be stored and used repeatedly to get new short-lived access tokens whenever needed, without the user manually reauthorizing the app. So, once you have the refresh token, no further browser interaction is required for that account.

 

We highly recommend using the official Dropbox Python SDK, which will handle the refresh process for you automatically. To set that up, make sure you're using the SDK as shown in the examples:

Once you have the refresh token, you can set up the client like shown at the end without manually running the authorization flow again.

ogurchik222
Explorer | Level 4
Go to solution

Thank you for your answers. I've found solution via using refresh token. It works for 2 days correctly already. IDK if I can share link from stackoverflow here, so I won't) 

Need more support?
Who's talking

Top contributors to this post

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