Ferenc Orosi
Ferenc Orosi

Reputation: 265

GET request in google drive api with api key

According to the google drive api's documentation, I can not write key parameter into the request. I tried this request with my folderID and my api key:

GET https://www.googleapis.com/drive/v3/files?q='folderID'+in+parents&key={API KEY}

The documentation page contains a try-out method where I tried out my request, I ticked only the API key in the credentials section. This also did not work.

Can I make requests with api key or not?

Upvotes: 1

Views: 1473

Answers (1)

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 116908

API keys are used for accessing public data. Not private user data.

The files.list requires that your application be authorized with one of the following scopes

enter image description here

trying to call files.list without authorizing the call using Oauth2 is going to result in the following error message

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "insufficientFilePermissions",
    "message": "The user does not have sufficient permissions for this file."
   }
  ],
  "code": 403,
  "message": "The user does not have sufficient permissions for this file."
 }
}

The only method in the google drive API that you would be able to use with an API key would probably be a file.get assuming that the file itself was set to public. As in shared with everyone.

Api keys are mostly used for apis like maps, or youtube searching for public videos.

Upvotes: 4

Related Questions