2

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
  • If you're using composer, you shouldn't need to change include_path at all. require_once 'vendor/autoload.php' should do the trick. Commented Jun 26, 2015 at 16:42

1 Answer 1

1

The class mentioned above is defined in the AppEngine PHP SDK, which is pulled in automatically when your code runs on AppEngine. It authenticates your AppEngine application with the Google APIs.

For local development, you will need to authenticate a different way. The best method is by using Service Account Credentials. I recommend upgrading to the latest version (v2) of the client library, where this is handled automatically.

Sign up to request clarification or add additional context in comments.

5 Comments

Hi, I just got back to look at this. And am having some trouble getting this to work. You got some concrete sample code how to authenticate a request to a GAE app? I find it hard to find any docs at Google that are to the point of that.
Hi Jonny. By "to a GAE app" what exactly are you trying to authenticate for? This library is used for making calls to Google APIs, not to apps running on Google App Engine.
I have an API I created myself at someapp.appspot.com/myapi - it needs admin authentication in order not to make that public. I'll use it to POST some data from another server periodically.
I had a working way of logging my script in as admin by using "sacsid" cookies - see the paragraph in my post above. I need something that does the same job again.
Try adding 'use google\appengine\api\app_identity\AppIdentityService;'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.