luongbs94 / google-api-java-client

Automatically exported from code.google.com/p/google-api-java-client
0 stars 0 forks source link

Copy a document which i am not owner #637

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Version of google-api-java-client (e.g. 1.5.0-beta)?
10.3-beta

Java environment (e.g. Java 6, Android 2.3, App Engine)?
java 6

Describe the problem.
If I try to copy a file with drive.files.copy 
(https://developers.google.com/drive/v2/reference/files/copy) in which I can 
write but I'm not owner, make the copy but return null.

Here is my code:

File file=null;

try {
      file = service.files().get(idDoc).execute();

    } catch (HttpResponseException e) {
      if (e.getStatusCode() == 401) {
        // Credentials have been revoked.
        // TODO: Redirect the user to the authorization URL.
        throw new UnsupportedOperationException();
      }
    } catch (IOException e) {
      System.out.println("An error occurred: " + e);
    }
File copiedFile= null;
try {
copiedFile= service.files().copy(idDoc, file).execute();
} catch (IOException e) {
      System.out.println("An error occurred: " + e);
}

copiedFile it's null.

And error code:

 com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 OK
{
  "code" : 403,
  "errors" : [ {
    "domain" : "global",
    "location" : "Authorization",
    "locationType" : "header",
    "message" : "The authenticated user does not have the required access to the file *****IDFILE******",
    "reason" : "userAccess"
  } ],
  "message" : "The authenticated user does not have the required access to the file *****IDFILE******"
}

The IDFILE is the id document of the new file.

How would you expect it to be fixed?

Return the copy.

Original issue reported on code.google.com by alv...@nubbius.com on 18 Oct 2012 at 11:40

GoogleCodeExporter commented 9 years ago
Please see this page for Google Drive support:
https://developers.google.com/drive/support

Thanks!

Original comment by yan...@google.com on 18 Oct 2012 at 12:19