cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Share your feedback on the Document Scanning Experience in the Dropbox App right here.

Discuss Dropbox Developer & API

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Re: Missing scope from request

Missing scope from request

PPT320
New member | Level 2
Go to solution

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.

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

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

View solution in original post

4 Replies 4

Greg-DB
Dropbox Staff
Go to solution

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
New member | Level 2
Go to solution

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
Dropbox Staff
Go to solution

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
New member | Level 2
Go to solution

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);
//}
}

 

Need more support?