无法使用 dropbox API v2 python 下载文件

cant download file using drpbox API v2 python

我正在尝试使用保管箱的 API v2 下载文件 这是我的代码:

#!/usr/bin/python2.7
import sys

import dropbox
from dropbox.files import WriteMode
from dropbox.exceptions import ApiError, AuthError

TOKEN = '{TOKEN}'



if __name__ == '__main__':
    # Check for an access token
    if len(TOKEN) == 0:
        sys.exit("ERROR: Looks like you didn't add your access token. ")

    # Create an instance of a Dropbox class, which can make requests to the API.
    print("Creating a Dropbox object...")

    with dropbox.Dropbox(TOKEN) as dbx:
        try:
            md, res = dbx.files_download(path='/test/dropbox_test.txt')
        except dropbox.exceptions.HttpError as err:
            print('*** HTTP error', err)
    print("Done!")

但我遇到了错误

BadInputError('1c38b505bb634f5985ef65e745c153f1', 'Error in call to API function "files/download": Your app is not permitted to access this endpoint because it does not have the required scope \'files.content.read\'. The owner of the app can enable the scope for the app using the Permissions tab on the App Console.')

我不明白这个错误以及如何修复它

Dropbox 现在使用“范围”来配置应用可以访问的功能。例如,使用 the files_download method, which calls the /2/files/download endpoint, the app needs the files.content.read scopes. You can find more information about scopes on Dropbox in the Dropbox OAuth Guide.

您可以通过 the App Console 上应用页面的“权限”选项卡为您的应用启用作用域。

请注意,这不会追溯影响现有的访问令牌,因此您需要在启用该范围后获取新的访问令牌。