Installing and using Google's PHP library for OAuth 2

时间:2015-06-26 10:16:35

标签: php google-app-engine google-api-php-client

In order to post/upload some stuff from my local php script (running on my machine) to a (my) GAE app, I am doing this:

https://developers.google.com/api-client-library/php/start/installation

I installed that library locally in the same folder where I use my uploading php script, using composer. The installation works fine, but I just don't understand what I need to do to be able to use the Google_Client() class etc in my script. The "Setting include_path dynamically in your code" does not really help and the steps to include that library properly seems to be missing.

Some background info: I used to be able to upload/post fine to my GAE app by getting "sacsid" cookies, until any of these reasons:

  • I enabled two-step verification on the account that I used to access the admin of the GAE app
  • Google deprecated that "sacsid" process.

I might very well be wrong about that stuff but I guess the official way these days is to use said php library for this right?

Specifically I tried this at the top of my script:

require_once 'vendor/autoload.php';

And I get

Fatal error: Class 'google\appengine\api\app_identity\AppIdentityService' not found in /vendor/google/apiclient/src/Google/Auth/AppIdentity.php on line 79

1 个答案:

答案 0 :(得分:1)

上面提到的类在AppEngine PHP SDK中定义,当您的代码在AppEngine上运行时会自动引入。它使用Google API对您的AppEngine应用程序进行身份验证。

对于本地开发,您需要以不同的方式进行身份验证。最好的方法是使用Service Account Credentials。我建议升级到客户端库的最新版本(v2),其中handled automatically