Vipin Garg
Vipin Garg

Reputation: 344

With Service account, Not getting any files / folder list with PHP

What will extra setting to get files / folder from google drive API with service account? Currently getting empty results.

Same code working with credential web scope with client id and secrets key but not with service account.

Upvotes: 2

Views: 2028

Answers (1)

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 116948

When you use a web client. It pops up and requests authorizaiton. In this way a user is granting your application access to their data. So a file.list will return the files on the users google drive account.

The same thing is happening with your service account. Only service accounts are pre authorized. Your file.list is returning no files becouse the service account doesnt have acess to any files yet. You see it has its own drive account.

Options.

  1. Upload files to the service accounts drive account.
  2. open your credetials.json file. Look for the service account email address. Take that address and share a directory or file on your personal drive account with the service account.

Now do a file.list. It should have files.

Upvotes: 5

Related Questions