Hello,
i'm using the google-api-php-client to authenticate a simple get
request to the analytics api. But i only get a 403 - forbidden
response.
Thats the way i did that:
1. i logged in at the google api console with an account wich has
access to the analytics account
2. i created a new service account within a project wich has access to
the analytics api
3. with the latest google-api-php-client i authenticated the request
to the analytics api by using this service account. The authentication
seems to work fine, as the request header contains "authorization:
Bearer {access_token}". But the response is always: {"error":{"errors":
[{"message":"Forbidden"}],"code":403,"message":"Forbidden"}}
When i authenticate the same api request via "Client ID for web
applications" (OAuth 2.0 Playground) i get my wanted response.
What i'am doing wrong?
Here is a short code snippet of what iam doing:
$client = new apiClient();
$client->setAssertionCredentials(new apiAssertionCredentials(
'{my service account email}',
array('
https://www.googleapis.com/auth/analytics.readonly'),
'{my service account certificate}'
));
$request = $client->getIo()->authenticatedRequest(new
apiHttpRequest('
https://www.googleapis.com/analytics/v3/data/ga?{my
query}'));
any ideas?