Search code examples
javascriptgoogle-docsrestful-authenticationgoogle-docs-api

Google Drive RESTful permissions


I'm trying to access some documents stored in a team Google Drive using JavaScript and Google's RESTful API.

I set up an API key in the developer console, and restricted it to my IP. Everything works fine for some documents - I can export a Google Doc as HTML and render it on my page. The same pages work in Postman, too.

However, some pages I get the following error:

{
    "error": {
        "errors": [
            {
                "domain": "global",
                "reason": "notFound",
                "message": "File not found: eg_xuQ5gXMWGPeUtf8mTZ7VhEYW_DIH6XK__lC1w0rMo",
                "locationType": "other",
                "location": "file"
            }
        ],
        "code": 404,
        "message": "File not found: eg_xuQ5gXMWGPeUtf8mTZ7VhEYW_DIH6XK__lC1w0rMo"
    }
}

I know the fileId is correct, yet I still get a notFound response. I suspect this is about permissions, but when I compare docs that work against ones that don't, I can't see any differences on the surface.


Solution

  • You may refer with this thread wherein the issue is with the access_token. Make sure that you are providing the correct access_token when making the GET request for file metadata. Try to regenerate the authorization code, access_token.

    Also, as stated in the documentation, error 404: File not found: {fileId} means that the user does not have read access to a file, or the file does not exist.

    Suggested action: Report to users that they do not have read access to the file or that the file does not exist. Tell them that they should ask the owner for permission to the file.

    Hope this helps!