Take Your Search Game to the Next Level with Dropbox Dash  🚀✨ Curious how it works? Ask us here! 

Forum Discussion

roberto_arista's avatar
roberto_arista
Explorer | Level 3
15 days ago

AuthError "files.content.read" does not match scopes of token

Hey!

I have a short python script, connecting and running a few files operation over my dropbox team folder.

Up until now I was able to upload and delete files, but since I tried to read files from there I was not able to do that. I realized that my token could miss the required permission, so I updated the app and then got a new refresh token with the following scopes:

account_info.read events.read files.content.read files.content.write files.metadata.read files.metadata.write files.permanent_delete files.team_metadata.read files.team_metadata.write groups.read members.read team_data.content.read team_data.content.write team_data.governance.read team_data.governance.write team_data.member team_data.team_space team_info.read team_info.write

Again, no luck, when running this:

from os import environ as env
from dotenv import load_dotenv
from dropbox import DropboxTeam
from dropbox.common import PathRoot

if __name__ == "__main__":

load_dotenv()
path_root = PathRoot.root(env["ROOT_FOLDER_ID"].strip())

client = (

DropboxTeam(

app_key=env["APP_KEY"].strip(),

app_secret=env["APP_SECRET"].strip(),

oauth2_refresh_token=env["REFRESH_TOKEN"].strip(),

)

.with_path_root(path_root)

.as_user(env["USER_ID"].strip())

)

client.files_download_to_file("hello.json", path="/my dropbox folder/hello.json")
 

I get the following exception

dropbox.exceptions.AuthError: AuthError('c45f5e7719c7490b89f2fa6af930df5d', AuthError('missing_scope', TokenScopeError(required_scope='files.content.read')))

 

Any idea of what might be going on?

4 Replies

  • roberto_arista's avatar
    roberto_arista
    Explorer | Level 3

    I ended solving by creating a new app from scratch with the correct permissions.

  • DB-Des's avatar
    DB-Des
    Icon for Dropbox Engineer rankDropbox Engineer

    Hi roberto_arista,

    A '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. Also, be aware that just adding a scope to your app via the App Console does not retroactively grant that scope to existing access tokens or refresh tokens.

    You mentioned you updated the app and then got a new refresh token, however, to make any API calls that require any updated scopes, you'll need to re-authorize the app to get a new access token (and refresh token, if being used) with the updated scope(s).

    I hope this information provides more clarity!

    • roberto_arista's avatar
      roberto_arista
      Explorer | Level 3

      Hey DB-Des, thanks for your answer. I've also re-authorized after setting the new scopes. I guess I need to delete this app and start fresh with a new one.

      • DB-Des's avatar
        DB-Des
        Icon for Dropbox Engineer rankDropbox Engineer

        Hi roberto_arista​,

        I'm glad to hear you were able to get this working. Just for future reference, it is not necessary to delete an app and create a new one in order to grant new scopes.

        Checking/Unchecking scopes and clicking "Submit" at the bottom of the page should save the updated scopes. After that step's been taken, and the updated scopes confirmed, users can re-authorize the existing app with the updated scopes.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,000 PostsLatest Activity: 3 days ago
382 Following

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!