Service accounts do not work with any service tied to a user account. You need to look at oauth using a refresh_token. Not at the office yet so I can't give you some example code
Eric Haskins
Sent from my Samsung smartphone on AT&T
Mohamed Chenouili <
mchen...@gmail.com> wrote:
Hello,
I tried the service Account for GA with the new PHP version of google API, the one from trunk
and i get invalid_grant error
So i did generate a key for service account,
the service Account name was added in my Google analytics account as a user
and here is the code. I have no clue as for the reason for this error.
I tried it with prediction API and still the same error but as it is prediction request is costly
i don't know if it is the reason for the 'invalid_grant' error
session_start();
const CLIENT_ID = 'CLIENT_ID';
const SERVICE_ACCOUNT_NAME = 'SERVICE_ACCOUNT_NAME';
const KEY_FILE = './PATH_TO_KEYFILE.p12';
$client = new apiClient();
$client->setApplicationName("NAME_APPLICATION");
$key = file_get_contents(KEY_FILE);
$client->setAssertionCredentials(new apiAssertionCredentials(
SERVICE_ACCOUNT_NAME,
array('
https://www.googleapis.com/auth/prediction'),
$key)
);
$client->setClientId(CLIENT_ID);
$service = new apiAnalyticsService($client);
echo getFirstprofileId($service);
I get the error : invalid_grant i try to find another solution but no luck so far
Could you tell me what i am doing wrong ???
and if there is another solution to get the data from my GA account with automatic authentification
(how to generate an access token for each session,...) ???
Le jeudi 19 juillet 2012 12:31:42 UTC+2, robin a écrit :
Hi
who know that GA will support serviceaccount?
在 2012年4月13日星期五UTC+8上午3时58分45秒,andrew...@fcc.gov写道:I downloaded the latest file today and am attempting to run the the
service account example here -
http://code.google.com/p/google-api-php-client/source/browse/trunk/examples/prediction/serviceAccount.php
I get this error -
Fatal error: Call to undefined method
apiClient::setAssertionCredentials() in Google_Analytics_API\index.php
on line 44
My index.php is the serviceAccount.php with include paths changed and
the key file, client id and service account name changed.
But that none of that seems to matter based on the error above.
Looking through the files pretty quickly that method doesn't exist
anywhere.
Any ideas? Am I missing some files? Did I get the wrong files? Again,
I downloaded the latest just today from here -
http://code.google.com/p/google-api-php-client/downloads/list
Any ideas???