Why can't I log in to Google API?

$client = new Google_Client();
 $client->setApplicationName('People API PHP Quickstart');
$client->setScopes([Google_Service_Drive::DRIVE]);
$client->setAuthConfig('client_secret_323157009558-rkb73ai9842ndkq7efrpvk3f4dtkesn0.apps.googleusercontent.com.json');
$client->setHostedDomain('localhost');


 if ($client->getRefreshToken()) {
$client->fetchAccessTokenWithRefreshToken($client->getRefreshToken());
 } else {
 echo 's';
 }


The file for authorization client_secret_323157009558-rkb73ai9842ndkq7efrpvk3f4dtkesn0.apps.googleusercontent.com.json:

{"web":{"client_id":"323157009558-rkb73ai9842ndkq7efrpvk3f4dtkesn0.apps.googleusercontent.com","project_id":"zakajibuket-uploader","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://www.googleapis.com/oauth2/v3/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"O8w2fQbIjbkbCe-HRFIEWKtB","redirect_uris":["http://localhost"],"javascript_origins":["http://localhost"]}}


Error such as:

sobject(Google_Service_Exception)#25 (8) { ["errors":protected]=> array(1) { [0]=> array(5) { ["domain"]=> string(6) "global" ["reason"]=> string(8) "required" ["message"]=> string(14) "Login Required" ["locationType"]=> string(6) "header" ["location"]=> string(13) "Authorization" } } ["message":protected]=> string(238) "{ "error": { "errors": [ { "domain": "global", "reason": "required", "message": "Login Required", "locationType": "header", "location": "Authorization" } ], "code": 401, "message": "Login Required" } } "["string":"Exception":private]=> string(0) "" ["code":protected]=> int(401) ["file":protected]=> string(68) "C:\xampp2\htdocs\ph\vendor\google\apiclient\src\Google\Http\REST.php" ["line":protected]=> int(118) ["trace":"Exception":private]=> array(7) { [0]=> array(6) { ["file"]=> string(68) "C:\xampp2\htdocs\ph\vendor\google\apiclient\src\Google\Http\REST.php" ["line"]=> int(94) ["function"]=> string(18) "decodeHttpResponse" ["class"]=> string(16) "Google_Http_REST" ["type"]=> string(2) "::" ["args"]=> array(3) { [0]=> object(GuzzleHttp\Psr7\Response)#27 (6) { ["reasonPhrase":"GuzzleHttp\Psr7\Response":private]=> string(12) "Unauthorized" ["statusCode":"GuzzleHttp\Psr7\Response":private]=> int(401) ["headers":"GuzzleHttp\Psr7\Response":private]=> array(8) { ["X-GUploader-UploadID"]=> array(1) { [0]=> string(98) "AEnB2UqTiUNaUerDLJmk0bSt4RPckIW2zdyfstrdcbrjjnsxubvcvktu80afct3dehxirhxrg5ve27lql9n4rbn_p20ffirrdq" } ["Vary"]=> array(2) { [0]=> string(6) "Origin" [1]=> string(8) "X-Origin" } ["WWW-Authenticate"]=> array(1) { [0]=> string(43) "Bearer realm="https://accounts.google.com/"" } ["Content-Type"]=> array(1) { [0]=> string(31) "application/json; charset=UTF-8" } ["Content-Length"]=> array(1) { [0]=> string(3) "238" } ["Date"]=> array(1) { [0]=> string(29) "Wed, 10 Oct 2018 00:32:32 GMT" } ["Server"]=> array(1) { [0]=> string(12) "Upl
March 12th 20 at 08:04
1 answer
March 12th 20 at 08:06
"Authorization" } ], "code": 401, "message": "Login Required" } } "
Yes - but the data is correct for authorization - Veronica_Larkin commented on March 12th 20 at 08:09
Well, logically, you pass him the key and the login anyone login no.
What is actually said in error. - Rosemarie90 commented on March 12th 20 at 08:12

Find more questions by tags Google DriveAPIGoogle