I'm new in Python and start playing around to access different API and now I got to Dropbox APIs. But I got a "invalid_grant" access when I try to access my own account.
import dropbox
app_key = 'AAAA'
app_secret = 'BBBB'
flow = dropbox.client.DropboxOAuth2FlowNoRedirect(app_key, app_secret)
authorize_url = 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.')
code = 'CCCC'
access_token, user_id = flow.finish(code)
When I runt this script I got following output.
Traceback (most recent call last): File "PATH/dropboxdownload.py", line 14, in access_token, user_id = flow.finish(code) File "PATH\Python35-32\lib\site-packages\dropbox-2.2.0-py3.5.egg\dropbox\client.py", line 1398, in finish return self._finish(code, None) File "PATH\Python35-32\lib\site-packages\dropbox-2.2.0-py3.5.egg\dropbox\client.py", line 1265, in _finish response = self.rest_client.POST(url, params=params) File "PATH\Python35-32\lib\site-packages\dropbox-2.2.0-py3.5.egg\dropbox\rest.py", line 316, in POST return cls.IMPL.POST(*n, **kw) File "PATH\Python35-32\lib\site-packages\dropbox-2.2.0-py3.5.egg\dropbox\rest.py", line 254, in POST post_params=params, headers=headers, raw_response=raw_response) File "PATH\Python35-32\lib\site-packages\dropbox-2.2.0-py3.5.egg\dropbox\rest.py", line 227, in request raise ErrorResponse(r, r.read()) dropbox.rest.ErrorResponse: [400] 'invalid_grant' Process finished with exit code 1
access_token
to that value and move on. – user94559