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.