4

I have created an App that is supposed to copy a publicly shared Google Document to the logged-in user's Google Drive. It works well if the scope is set to https://www.googleapis.com/auth/drive, but if I restrict it to https://www.googleapis.com/auth/drive.file, I see the following error:

req-url: https://content.googleapis.com/drive/v3/files/1vpJM9XgJzBI6oHAZCupRTF0TdIvgiq5tTl1kYFt8zLg/copy?alt=json&key=AIzaSyAON3JJQtrQYO3RcuRQo7BnFw8hzVkEDUE
req-payload: {"name":"Invoice 23rd Apr 11:06pm","parents":["1mnBEoqL677quoLGpKHY-2kzh8j7WU-Od"]}

response:
{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "notFound",
    "message": "File not found: 1vpJM9XgJzBI6oHAZCupRTF0TdIvgiq5tTl1kYFt8zLg.",
    "locationType": "parameter",
    "location": "fileId"
   }
  ],
  "code": 404,
  "message": "File not found: 1vpJM9XgJzBI6oHAZCupRTF0TdIvgiq5tTl1kYFt8zLg."
 }
}

NOTE the src file is publicly available at https://docs.google.com/document/d/1vpJM9XgJzBI6oHAZCupRTF0TdIvgiq5tTl1kYFt8zLg/edit?usp=sharing

סטנלי גרונן
  • 2,917
  • 23
  • 46
  • 68
Amarsh
  • 11,214
  • 18
  • 53
  • 78
  • If "copy" is to copy a shared Google Document to user's Google Drive, how about using [the method of Files: copy](https://developers.google.com/drive/api/v3/reference/files/copy)? In this case, I think that the scope of ``https://www.googleapis.com/auth/drive.file`` can be used for copying files. So how about using this endpoint? ``POST https://www.googleapis.com/drive/v3/files/1vpJM9XgJzBI6oHAZCupRTF0TdIvgiq5tTl1kYFt8zLg/copy`` The request body is the same with yours. If I misunderstood your question and this was not resolved your issue, I apologize. – Tanaike Apr 23 '19 at 23:35
  • I guess I am using the same method that you have pointed to. What I have put here is what `network-tab` in Chrome shows me. I am actually using the google's client api ( https://developers.google.com/api-client-library/javascript/ ). The url https://content.googleapis.com/drive/v3/files/1vpJM9XgJzBI6oHAZCupRTF0TdIvgiq5tTl1kYFt8zLg/copy is what the client sdk is producing – Amarsh Apr 24 '19 at 04:25
  • Thank you for replying. I couldn't notice that you are using Javascript and the files.copy method from your question. I apologize my comment was not useful for your situation. And also I have to apologize for my poor English skill. – Tanaike Apr 24 '19 at 06:57
  • 2
    Many thanks @Tanaike . You are a wonderful person and your English is very good. I will try to find the correct answer and will post it here. – Amarsh Apr 24 '19 at 11:48

0 Answers0