Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing scope error Dropbox API authentication?

I'm trying to download a large Dropbox folder with a bunch of subfolders to an external harddrive using the scripts at: http://tilburgsciencehub.com/examples/dropbox/

import dropbox
from get_dropbox import get_folders, get_files
from dropbox.exceptions import ApiError, AuthError


# read access token
access_token = "sl.superlongstring"
 

print('Authenticating with Dropbox...')
try:
    dbx = dropbox.Dropbox(access_token, scope=['files.content.read', 'files.metadata.read'])
    print('...authenticated with Dropbox owned by ' + dbx.users_get_current_account().name.display_name)
except AuthError as err:
    print(err)

no errors here , correctly displays my name.

try:
    folders=get_folders(dbx, '/Audioboeken')
    print(folders)
    download_dir = r'L:\\00 Audioboeken'
    print('Obtaining list of files in target directory...')
    get_files(dbx, folder_id, download_dir)
except ApiError as err:
    print(err)
except AuthError as autherr:
    print(autherr)

This errors:

dropbox.exceptions.AuthError: AuthError('randomstringofnumbers, AuthError('missing_scope', TokenScopeError(required_scope='files.metadata.read')))

I've tried adding scope to the login request, but that doesn't seem to help..(not sure if I did that correctly)

App Permissions: The checkbox for files.content.read and files.metadata.read are checked.

like image 210
user1692094 Avatar asked Dec 01 '22 08:12

user1692094


1 Answers

The 'missing_scope' error indicates that while the app is permitted to use that scope, the particular access token you're using to make the API call does not have that scope granted. Adding a scope to your app via the App Console does not retroactively grant that scope to existing access tokens.

That being the case, to make any API calls that require that scope, you'll need to get a new access token with that scope.

like image 50
Greg Avatar answered Dec 05 '22 03:12

Greg