Answer the question
In order to leave comments, you need to log in
How to get Google analytics access_token?
Guys, I've been trying to get an access_token for the second day already.
All examples use redirect_uri. I don't have it.
But I only have a key in the form of json:
{"web":{
"client_id":"6xxxxxxxx-yyyyyyy",
"project_id":"api-project-xxxxxx",
"auth_uri":" https://accounts.google .com/o/oauth2/auth ",
"token_uri":" https://accounts.google.com/o/oauth2/token ",
"auth_provider_x509_cert_url":" https://www.googleapis.com/oauth2/v1 /certs ",
"client_secret":"xxxxx"}}
Please tell me to get access_token!!!
Or poke your nose into a working example. I already downloaded the google API
for PHP through composer, but nothing works :(((
Answer the question
In order to leave comments, you need to log in
https://developers.google.com/analytics/devguides/...
https://developers.google.com/identity/protocols/O...
Try like this:
$client = new \Google_Client();
$client->setAuthConfig('абсолютная ссылка на конфиг'); //или туда массив передать
// задаем права
$client->addScope([
'https://www.googleapis.com/auth/analytics.edit',
'https://www.googleapis.com/auth/analytics',
]);
$service = new \Google_Service_Analytics($client); // или любой другой, например Google_Service_AnalyticsReporting
// далее через $service получаем/записываем/меняем все что нужно
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question