Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to access datastore in another project? #145

Closed
haotung opened this issue Oct 11, 2016 · 4 comments
Closed

How to access datastore in another project? #145

haotung opened this issue Oct 11, 2016 · 4 comments

Comments

@haotung
Copy link

haotung commented Oct 11, 2016

I tried to access datastore in another project. I have downloaded credentials JSON file and put it into credentials folder.

Here is my code:

putenv('GOOGLE_APPLICATION_CREDENTIALS=credentials/my-another-project.json');
require_once('php-gds-master/vendor/autoload.php');
$obj_gateway_remote = new \GDS\Gateway\RESTv1('my-another-project');

$obj_store = new GDS\Store('device', $obj_gateway_remote);
$deviceEntities = $obj_store->fetchPage(20);
print_r($deviceEntities);

And I got the error:

PHP Fatal error: Uncaught exception 'InvalidArgumentException' with message 'json key is missing the type field' in /base/data/home/apps/s~ht-courses/1.396256133006308724/php-gds-master/vendor/google/auth/src/CredentialsLoader.php:118

Please tell me any steps I missed. Thank you.

@haotung
Copy link
Author

haotung commented Oct 11, 2016

I found that I downloaded wrong JSON file.
The correct JSON file should be downloaded from "IAM & Admin -> Server Accounts -> App Engine default service account -> Create Key
Furthermore, "php_sapi_name" function should be enabled in php.ini

However, the program always gets no errors but "exceeded the maximum execution time".

Does anyone have the same experience?

@tomwalder
Copy link
Owner

Where are you running the code?

App Engine? Compute Engine?

@haotung
Copy link
Author

haotung commented Oct 13, 2016

I run it on App Engine.

@tomwalder
Copy link
Owner

Sounds like this is related to #135

Generally, running on AppEngine, you would be expected to use the Protocol Buffer API & Gateway.

And also, access the "current" project - although I have not tried to access a different project with the Protocol Buffer API, it may well be possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants