2013-10-02 15:53 浏览 170


I've now spent hours making this work and I'm running out of documentation to read on how to get such a simple process to work correctly. Here's my ideal situation.

I have a javascript version of the Google Drive picker (too me a couple hours to finally figured out the thing that I wanted google called the Google Picker API). Once I found it, it works like a charm and everything I ever hoped it would be. (kinda). What I need to have happen is the picker returns the file_id (which it does) and then I use that file ID in a php script to fetch the file through a wget call and then I save the file on my server. I haven't been able to get a curl request to work right so I used googles php library, which I'd rather not use, but whatever will make it work.

My glaringly huge problem is I have tried through the javascript api and the php api and even google's own explorer api and I get a file not found error on any file I choose from the several different google drive accounts I've attempted. I've been able to fix the myriad of descriptive (or lack thereof) errors and I'm finally settling down to this one error I cannot get passed. The javascript api returns a error 400 "Required Value: id" even though I know the value is getting populated correctly. The php library returns an error 404: File Not Found

I have Google Drive API enabled and running. I have Google Drive SDK enabled and appears to be working properly. I've read elsewhere that this could be a file permissions error, but I have no direction on how to correct this if it even is the problem.

For the record, I also had to do a dropbox integration, and entire integration from start to finish was less than 30 minutes.


Just in case I'm missing something with my api keys (there are way too many), for the picker, I need to the following from the Google Cloud interface. The .setDeveloperKey which is the Browser Key API Key, the .setAppId is the Oauth 2.0 client id.

When I setup the php library and am building up the client, $client->setClientId() is my Oauth 2.0 client id and $client->setDeveloperKey() is my Server Key API Key correct?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答 默认 最新

  • 已采纳
    dongtui4038 dongtui4038 2013-10-02 20:08

    You need to authorize and authenticate your requests on the behalf of the user, a key and your client ID will not be enough to access user's non-public document. Auth for PHP is explained on https://developers.google.com/drive/quickstart-php

    点赞 评论 复制链接分享
  • duanliaoyin3171 duanliaoyin3171 2014-09-04 17:18

    In my case it turned out to be a problem with scopes. When I used 'https://www.googleapis.com/auth/drive.file' I got 404 for any file. However when I used 'https://www.googleapis.com/auth/drive.readonly', I can get the meta data and exportLink for downloading file contents, etc.

    Per https://developers.google.com/drive/web/scopes, the 'file' scope gives access to files created or opened by the app, while the 'readonly' scope does not have this constraint.

    点赞 评论 复制链接分享