We Want to Hear From You! What Do You Want to See on the Community? Tell us here!

Forum Discussion

PPT320's avatar
PPT320
New member | Level 2
5 years ago
Solved

Missing scope from request

Hi,

 

I'm looking for some help setting up an Android app with the api.

I am looking to list all files in a dropbox folder, select one to download and then read it into my app to process the data. The initial download is very similar to the Android SDK example but even that isn't working properly as it, like my app, creates an empty local file and the DownloadFileTask.java shows an error. I've traced this to 

 

2021-05-21 10:01:02.336 10188-10188/com.example.********.  E/com.example.********.FilesActivity: Failed to download file.
d.a.a.s: {"error_summary": "missing_scope/.", "error": {".tag": "missing_scope", "required_scope": "files.content.read"}}

 

In the developer app centre I definitely have file.content.read clicked and I have removed all data from my app and uninstalled. On reinstallation it asks me to login to dropbox which I assume then re-authenticates the app, which should have the scope set.  Neither the SDK example nor my app is actually creating the file

 

I have the app-key set in R.string.app_key and also in the manifest in the AuthActivity section, although I don't have an activity in my app called AuthActivity, so not sure why it should be there.

 

Please help as this is holding me up.

  • You can actually do either.

     

    If you want it to default to whatever is set for the app on the App Console at that point in time, you should pass in null.

     

    If you want to be specifically defined by the code, even if additional scopes are added to the App Console, you should pass the specific desired scope list. (Note that you can't request scopes that aren't enabled for the app though.)

4 Replies

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    5 years ago

    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. 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.

     

    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. It sounds like you've already done so though, so I also recommend checking the code you're running to process the authorization flow itself. While the scopes you enable on the App Console are used as the default scopes for the app, the app can also optionally specify a smaller set of scopes at authorization time. For example in this line of code in the sample app, it only requests "account_info.read" and "files.content.write". You would need to modify that if you want to request "files.content.read" as well.

  • PPT320's avatar
    PPT320
    New member | Level 2
    5 years ago

    Thanks for your reply Greg,

     

    So do you mean remove the arrays completely to force use of defaults, like

    DropboxActivity.startOAuth2Authentication(UserActivity.this, getString(R.string.app_key), null);

    or actually add the files.content.read like

    DropboxActivity.startOAuth2Authentication(UserActivity.this, getString(R.string.app_key), Arrays.asList("account_info.read", "files.content.read", "files.content.write"));

     I would prefer if it called all be controlled from the app on dropbox/developer

     

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    5 years ago

    You can actually do either.

     

    If you want it to default to whatever is set for the app on the App Console at that point in time, you should pass in null.

     

    If you want to be specifically defined by the code, even if additional scopes are added to the App Console, you should pass the specific desired scope list. (Note that you can't request scopes that aren't enabled for the app though.)

  • PPT320's avatar
    PPT320
    New member | Level 2
    5 years ago

    Thanks Greg, 

    I changed it to null and after initially failing because the example app then tried to open the file but its format won't allow it. I commented out the link to view the file and its now appears to be working. Thanks for your help.

     

    new DownloadFileTask(FilesActivity.this, DropboxClientFactory.getClient(), new DownloadFileTask.Callback() {
    @Override
    public void onDownloadComplete(File result) {
    dialog.dismiss();

    //if (result != null) {
    // viewFileInExternalApp(result);
    //}
    }

     

About Discuss Dropbox Developer & API

Node avatar for Discuss Dropbox Developer & API
Make connections with other developers814 PostsLatest Activity: 3 days ago
276 Following

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

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!