Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check 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 agoThat error indicates that you're attempting to use an object that isn't defined. Since you're trying to access a client with the name "dbx", add "as dbx" at the end of the "with" statement (before the ":"), like this:
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') as dbx:
(Or, you can still do it the other way, like "dbx = dropbox.Dropbox(...)" as long as you fill in credentials like above.)
Sufiyanashraf
3 years agoExplorer | Level 3
I corrected but again error
import sys
import dropbox
from dropbox import DropboxOAuth2FlowNoRedirect
from dropbox.files import WriteMode
import time
while True:
with dropbox.Dropbox(oauth2_access_token='sl access token',
oauth2_access_token_expiration=14400,
oauth2_refresh_token='refresh token',
app_key='app key',
app_secret='app secret') as dbx:
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)Showing error: "An error occurred: '>=' not supported between instances of 'datetime.datetime' and 'int'"
- Greg-DB3 years ago
Dropbox Community Moderator
This error is indicating that oauth2_access_token_expiration requires a datetime, but you're now passing in an int. You should pass in a datetime for that. Or, you can just omit oauth2_access_token_expiration entirely and the SDK will just handle it as needed.
- Sufiyanashraf3 years agoExplorer | Level 3
Remove this line?
oauth2_access_token_expiration=14400,
- Greg-DB3 years ago
Dropbox Community Moderator
Yes, either remove it or supply the correct type (datetime).
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
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!