1
votes

I would like to fetch data from Google Play Analytics which is stored in Google Cloud Storage. After researching lot discovered that there is no direct API to get Google Play Analytics report data. Hence I found Access Google play account reports through Google API Client PHP Library link and followed the same given. I have created service account, given owner permission, and enabled google cloud api too.

In the code shown in the link i am getting junk data if i var_dump($bucket) , and if run the further code , i get this error.

Fatal error: Uncaught exception 'Google\Cloud\Exception\ServiceException' with message '{ "error": { "errors": [ { "domain": "global", "reason": "forbidden", "message": "Caller does not have storage.objects.list access to bucket I cannot show any JS fiddle as the bucket name and other information like key is confidential to company. Here is code i used,

require 'vendor/autoload.php'; 
use Google\Cloud\Storage\StorageClient; 
$client = new StorageClient([ 'projectId'=> 'myproject-id','scopes'=> [StorageClient::READ_ONLY_SCOPE],'keyFile'=> json_decode(file_get_contents('path_to_jsonfile'), true) ]);                                  $bucket=$client->bucket('mybucketname'); 
/*Find bucket name in Google Developer Console>>Reports */ 
$buckets=$client->buckets([ 'prefix' => 'stats/installs/']); 
foreach ($buckets as $bucket) {echo $bucket->name().PHP_EOL; }

Accepting some help. Please tell me some solution. Thanks in advance

2
I think you should check line 153 of your code. We cant help you with out seeing your code.DaImTo
Authentication requirements can be different depending what device is attempting to reach Cloud Storage. Where is this code being run? Do all your bucket names start with the stats/installs/ prefix?Nicholas

2 Answers

1
votes

I found out that in addition to having "View Financial Data" you need to enable "View App Information" -permission (on Global level). Edit Google API permissions

Under Google Play Developer Console (all applications) -> Settings -> Developer Account -> API Access -> Grant Access .

0
votes

Indeed, more information details on the structure of your code are needed, to provide a definitive solution, as stated in the above comment. Judging by the error received and the code portion copied below it, your app might be skipping a needed stage, if we look at the “Google\Cloud\Storage\StorageClient” documentation page, namely the lines starting with: use Google\Cloud\ServiceBuilder; .

Also, the credentials stored in the JSON might be incorrect. Have you created credentials on the instance through the gcloud auth login command?