File not found error Google Drive API

前端 未结 3 1118
不思量自难忘°
不思量自难忘° 2020-12-10 17:34

I am using the Drive REST API to download a file. I am making a GET request using the file id and I get a file not found exception.

{
 \"error\"         


        
相关标签:
3条回答
  • 2020-12-10 18:02

    This is resolved. I wasn't providing the correct access_token when making the GET request for file metadata. I regenerated the authorization code, access_token and my code is working now.

    0 讨论(0)
  • Make sure scopes are corrects

    var url = oauth2Client.generateAuthUrl({
    access_type: 'offline',
    scope: ['https://www.googleapis.com/auth/drive.file',
        'https://www.googleapis.com/auth/drive',
        'https://www.googleapis.com/auth/drive.file',
        'https://www.googleapis.com/auth/drive.metadata'
      ]
    });
    

    Drive API declares the following scopes. Select which ones you want to grant to APIs Explorer.

    • https://www.googleapis.com/auth/drive View and manage the files in your Google Drive
    • https://www.googleapis.com/auth/drive.appdata View and manage its own configuration data in your Google Drive
    • https://www.googleapis.com/auth/drive.file View and manage Google Drive files and folders that you have opened or created with this app
    • https://www.googleapis.com/auth/drive.metadata View and manage metadata of files in your Google Drive
    • https://www.googleapis.com/auth/drive.metadata.readonly View metadata for files in your Google Drive
    • https://www.googleapis.com/auth/drive.photos.readonly View the photos, videos and albums in your Google Photos
    • https://www.googleapis.com/auth/drive.readonly View the files in your Google Drive
    • https://www.googleapis.com/auth/drive.scripts Modify your Google Apps Script scripts' behaviour

    Sorce: https://developers.google.com/apis-explorer/#p/drive/v3/drive.files.get

    0 讨论(0)
  • 2020-12-10 18:22

    In my case, I was using the file client_secret.json that I had created with the gmail address I use all the time, but I was creating the credentials with another e-mail.

    0 讨论(0)
提交回复
热议问题