1

Trying to get my head around the Google Drive API and being stuck on if I can get folders just via API key bypassing the OAuth2 authorization.

Particularly referring to this thread , which states it is simply possible by doing:

https://www.googleapis.com/drive/v2/files?q='FOLDERID'+in+parents&key=APIKEY

I'm getting an authorisation issue although the API key is correct. Also I find the ' ' really weird so I tried without and it gives me a 404. Any help is much appreciated.

Jason
  • 628
  • 3
  • 10
supersize
  • 13,764
  • 18
  • 74
  • 133
  • 2
    When the files in a folder are retrieved by drive.files.list using the API key, the folder is required to be shared. For example, as a test, how about sharing a sample folder and try it again? At that time, please do the urlencode to the endpoint like ``https://www.googleapis.com/drive/v2/files?q=%27FOLDERID%27+in+parents&key=APIKEY``. And then, please confirm whether Drive API is enabled at API console. If this information was not useful for your situation, I'm sorry. – Tanaike Oct 06 '18 at 22:51
  • Thanks for your comment. I know it is possible to make files public via Share -> advanced -> public. But I don't see this option for folders itself. It seems that folders by itself are just accessible via `folderId` automatically or can be shared via email? I might be missing something here. – supersize Oct 07 '18 at 09:10
  • Hey actually thanks, encoding worked! – supersize Oct 07 '18 at 12:49
  • 2
    Thank you for replying. When your issue was solved, can you post it as an answer and accept it? I think that this will be useful for other users who have the same issue. – Tanaike Oct 07 '18 at 22:49

1 Answers1

1

For whomever it may be helpful but the issue is solved by URL encoding the ':

https://www.googleapis.com/drive/v2/files?q=%27FOLDER_ID%27+in+parents&key=KEY_ID

and it works just fine.

supersize
  • 13,764
  • 18
  • 74
  • 133