google-workspacegoogle-picker

From the Google Picker, after selecting the file, I receive a "file not found" error in the backend integration


Our application encounters an error from Google Drive when attempting to download a selected file from the Google Picker.

We have two applications, one for the production environment and one for the development environment, which is in test mode (unverified) on Google Developer Console.

Both applications have the same scopes:

.../auth/userinfo.email
.../auth/userinfo.profile
.../auth/drive.file app
.../auth/drive.install

and the same configurations, albeit on different servers (or at least we believe so).

In the test environment, everything works correctly, while in the production environment, the error occurs.

We tested locally (on a development machine) using both the production app credentials and the test credentials and were able to replicate the error, tracing it back to the call to Drive.

Locally, with test credentials, we get this result:

curl -H "[AUTH_TOKEN]" https://www.googleapis.com/drive/v3/files/19MO3I3AWVmgj75DHzhm-O-j12dS8lZC_xxxxxxxxxxx

RESPONSE:

{
    "kind": "drive#file",
    "id": "19MO3I3AWVmgj75DHzhm-O-j12dS8lZC_xxxxxxxxxxx",
    "name": "recount jobs -",
    "mimeType": "application/vnd.google-apps.document"
}

Still locally, but with production credentials, we get this result:

curl -H "[AUTH_TOKEN]" https://www.googleapis.com/drive/v3/files/19MO3I3AWVmgj75DHzhm-O-j12dS8lZC_xxxxxxxxxxx

{
  "error": {
    "code": 404,
    "message": "File not found: 19MO3I3AWVmgj75DHzhm-O-j12dS8lZC_xxxxxxxxxxx.",
    "errors": [
      {
        "message": "File not found: 19MO3I3AWVmgj75DHzhm-O-j12dS8lZC_xxxxxxxxxxx.",
        "domain": "global",
        "reason": "notFound",
        "location": "fileId",
        "locationType": "parameter"
      }
    ]
  }
}

Note: Not all files have this problem. Additionally, if a malfunctioning file is opened via "Open with" from Google Drive, everything works correctly.

Is there perhaps some configuration issue that we're overlooking?


Solution

  • What fixed the issue for me was setting the appId as explained in one of the answers for this question.

    In my case I was leaving the appId blank as the react drive picker library I am using doesn't say anything about the appId in the docs.

    The problem is that the picker doesn't complain, letting the user select the file and returning the metadata in the callback, but when the user tries to download the file, the not found error is returned.