Monday, January 13, 2020

Digest for adsense-api@googlegroups.com - 1 update in 1 topic

Khoa Do Dinh <khoa.do@netlink.vn>: Jan 12 05:26PM -0800

Hi all,
 
We using (PHP code) to connect Google Adsense API:
 
$cred = __DIR__ .'/credentials.json'; (*this file download when we register
an account and enable Adsense API*)
$client = new Google_Client();
 
$client->setAuthConfig($cred);
$client->setAccessType( "offline" );
$client->setApprovalPrompt('force');
$client->setScopes(array('https://www.googleapis.com/auth/adsense.readonly
','https://www.googleapis.com/auth/adsense'));
 
$service = new Google_Service_AdSense($client);
 
But we recevei a message:
 
*Fatal error*: Uncaught exception 'Google_Service_Exception' with message
'{ "error": { "errors": [ { "domain": "global", "reason": "required",
"message": "Login Required", "locationType": "header", "location":
"Authorization" } ], "code": 401, "message": "Login Required" } } ' in
/home/
dashboard.net/public_html/adsense/vendor/google/apiclient/src/Google/Http/REST.php:118 Stack
trace: #0 /home/
dashboard.net/public_html/adsense/vendor/google/apiclient/src/Google/Http/REST.php(94):
Google_Http_REST::decodeHttpResponse(Object(GuzzleHttp\Psr7\Response),
Object(GuzzleHttp\Psr7\Request), 'Google_Service_...') #1 [internal
function]: Google_Http_REST::doExecute(Object(GuzzleHttp\Client),
Object(GuzzleHttp\Psr7\Request), 'Google_Service_...') #2 /home/
dashboard.net/public_html/adsense/vendor/google/apiclient/src/Google/Task/Runner.php(181):
call_user_func_array(Array, Array) #3 /home/
dashboard.net/public_html/adsense/vendor/g in */home/dashboard.net/public_html/adsense/vendor/google/apiclient/src/Google/Http/REST.php
<http://dashboard.net/public_html/adsense/vendor/google/apiclient/src/Google/Http/REST.php>* on
line *118*
 
Please let me know my error.
 
Thanks for your support!
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to adsense-api+unsubscribe@googlegroups.com.

No comments:

Post a Comment