0

Using Google Drive API v2 rev 75 I am attempting to insert a file into the AppData folder, however insertion fails with:

com.google.api.client.googleapis.json.GoogleJsonResponseException: 403

"The current scope does not allow use of the appdata folder"

The scope "https://www.googleapis.com/auth/drive.appdata" is specified in the API Console though, so I'm a little stuck.

The insertion code goes:

    File file = new File();
    file.setTitle("myfile");
    file.setDescription("configuration file");
    file.setMimeType("text/plain");
    file.setParents(Arrays.asList(new ParentReference().setId("appdata")));

    try {
        File file1 = service.files().insert(file, ByteArrayContent.fromString("text/plain", "some settings")).execute();
    } catch (IOException e) {
        log.severe("An error occured: " + e);
        return null;
    }

The authorisation code I use follows that detailed in the DrEdit [sample]( https://code.google.com/p/google-drive-sdk-samples/source/browse/java/src/com/google/drive/samples/dredit/CredentialMediator.java?r=54312a4a583d5a2ba546330a892c4b0aca75c00d)

Specific snippets of my code include:

public static final List<String> SCOPES = Arrays.asList(
        // Required to access and manipulate files.
        "https://www.googleapis.com/auth/drive.file",
        ...
        "https://www.googleapis.com/auth/drive.appdata");

...

CredentialMediator mediator = new CredentialMediator(req, authSecrets.getClientSecretsStream(), SCOPES);

...

GoogleAuthorizationCodeRequestUrl urlBuilder =
new GoogleAuthorizationCodeRequestUrl(
        secrets.getWeb().getClientId(),
        secrets.getWeb().getRedirectUris().get(0),
        scopes)
        .setAccessType("offline")
        .setApprovalPrompt("force");

Any ideas why I am getting this problem? Thanks.

bleeper
  • 186
  • 1
  • 12
  • Could you share snippets from your authorization code? – Burcu Dogan May 22 '13 at 11:23
  • Thanks @Burcu Dogan I have updated the question to include some detail on authorization. Do say if there is anything specific you would like to see a snippet of. – bleeper May 22 '13 at 14:17
  • is it possible for you to switch to the code on https://github.com/googledrive/dredit? We've recently moved. – Burcu Dogan May 23 '13 at 11:39
  • I can do, has the authorisation code been updated? Is there something you are aware of that could cause my issue? Thanks – bleeper May 24 '13 at 13:25
  • The auth is a little bit changed on the github version but in terms of feature set, it's identical. Could you also validate your access token by calling https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=? It should list drive.appdata as an authorized scope. – Burcu Dogan May 25 '13 at 18:22

0 Answers0