cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox 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: Access Token Can't be refreshed without refresh token and app key in Python

Access Token Can't be refreshed without refresh token and app key in Python

Sufiyanashraf
Explorer | Level 3

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://github.com/sufiyanashraf/dropboxhelp/blob/main/cantrefresh

 

10 Replies 10

Sufiyanashraf
Explorer | Level 3

For now this code is perfectly working but I still want to open this topic 4 hours more to confirm if program doesn't die after that!

import sys
import dropbox
from dropbox import DropboxOAuth2FlowNoRedirect
from dropbox.files import WriteMode
import time

while True:
    with dropbox.Dropbox(oauth2_access_token='<access token>',
                     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)
Need more support?