Your workflow is unique 👨💻 - tell us how you use Dropbox here.
Forum Discussion
Sufiyanashraf
3 years agoExplorer | Level 3
Access Token Can't be refreshed without refresh token and app key in Python
I am building an app in python to automatically update a file using dropbox API, but it shows an error after 4 hours however I can't find any mistake can you point out my mistake? My code Link: https...
Greg-DB
Dropbox Community Moderator
3 years agoIn order to get this working, please set up the client by supplying the refresh token, etc., to it directly, as shown in the example, so that it can perform the refresh process for you. That way, it can continue performing API calls successfully for more than four hours.
Sufiyanashraf
3 years agoExplorer | Level 3
So flow like this? It still shows an error.
import sys
import dropbox
import time
from dropbox import DropboxOAuth2FlowNoRedirect
from dropbox.files import WriteMode
while True:
with dropbox.Dropbox(oauth2_access_token='access token',
oauth2_access_token_expiration=expiry,
oauth2_refresh_token='refresh token',
app_key='app key',
app_secret='secret'):
try:
with open('rtk.txt', 'rb') as f:
file_contents = f.read()
dbx.files_upload(file_contents, '/rtk.txt', mode=dropbox.files.WriteMode('overwrite'))
except Exception as e:
print(f"An error occurred: {e}")
time.sleep(60)Error: An error occurred: name 'dbx' is not defined
About Dropbox API Support and Feedback
Get help with the Dropbox API from fellow developers and experts.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!