It's been a long journey.
I've researched all over the place. And it has been painful to find a solution.
I intend to do something, supposedly, simple. I need to show reports saved in AdSense and the user could search the results based on the time interval chosen.
It turns out that to obtain this information authorization is required. Of course users are not authorized to access AdSense.
I have tried these resources now: link, link
And I have followed the rules and guidelines.
My code is as follows:
require_once 'google-api-php-client-2.2.2/vendor/autoload.php';
putenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json'); //WITH REAL PATH
$client = new Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope('https://www.googleapis.com/auth/adsense.readonly');
$httpClient = $client->authorize();
// make an HTTP request
$response = $httpClient->get('https://www.googleapis.com/adsense/v1.4/accounts/pub-00000000/reports/saved');
The result is "unauthorized", "Fatal error", etc.
I am no expert on the subject and I am completely lost. I really need this to work!
Thank you for your attention and help.