Skip to content

Problem with refreshing token #420

Open
@hapicatto

Description

@hapicatto

I'm not making it work the SDK for renewing the authorization token, so after 4hs my apis stop working. Even the example returns error:

# YOU NEED TO INSERT YOUR APP KEY AND SECRET BELOW!
# Go to dropbox.com/developers/apps to create an app.
from selenium import webdriver
import dropbox
app_key = MY KEY
app_secret = MY SECRET

auth_flow = dropbox.DropboxOAuth2FlowNoRedirect(consumer_key=app_key, consumer_secret=app_secret, token_access_type='offline')

authorize_url = auth_flow.start()
print("1. Go to: " + authorize_url)
print("2. Click \"Allow\" (you might have to log in first).")
print("3. Copy the authorization code.")
auth_code = input("Enter the authorization code here: ").strip()

try:
    oauth_result = auth_flow.finish(auth_code)
except Exception as e:
    print('Error: %s' % (e,))
    exit(1)

with dropbox.Dropbox(oauth2_refresh_token=oauth_result.refresh_token, app_key=app_key) as dbx:
    dbx.users_get_current_account()
    print("Successfully set up client!")

it returns:

1. Go to: https://www.dropbox.com/oauth2/authorize?response_type=code&client_id=jk6ig4490l1ssa0&token_access_type=offline
2. Click "Allow" (you might have to log in first).
3. Copy the authorization code.
Enter the authorization code here: I INPUT THE CODE
Traceback (most recent call last):
  File "C:\Users\herna\Documents\VideoProcessingProject\renovating.py", line 23, in <module>
    dbx.users_get_current_account()
  File "C:\Users\herna\anaconda3\envs\intel\lib\site-packages\dropbox\base.py", line 5090, in users_get_current_account
    r = self.request(
  File "C:\Users\herna\anaconda3\envs\intel\lib\site-packages\dropbox\dropbox.py", line 292, in request
    self.check_and_refresh_access_token()
  File "C:\Users\herna\anaconda3\envs\intel\lib\site-packages\dropbox\dropbox.py", line 357, in check_and_refresh_access_token
    self.refresh_access_token(scope=self._scope)
  File "C:\Users\herna\anaconda3\envs\intel\lib\site-packages\dropbox\dropbox.py", line 397, in refresh_access_token
    res.raise_for_status()
  File "C:\Users\herna\anaconda3\envs\intel\lib\site-packages\requests\models.py", line 943, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.dropboxapi.com/oauth2/token

I'm using a windows machine with the intel python version 3.7 as I'm using it in combination with tensorflow
I've tried every possible SO post but not sure where the error can be.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions