K
K
Konstantin2018-10-10 03:35:50
Google
Konstantin, 2018-10-10 03:35:50

Why can't I login 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 authorization file itself is 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"]}}

View error:
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) {) "Origin" [1]=> string(8) "X-Origin" } ["WWW-Authenticate"]=> array(1) { [0]=> string(43) "Bearer realm="string(98) "AEnB2UqTiUNaUerDLJmk0bSt4RPckIW2zDyfsTrDCBrJjnSXUBvcVKTU80afct3DEHXIrhxrg5VE27lqL9N4rBN_P20ffirRdQ" } ["Vary"]=> array(2) { [0]=> string(6) "Origin" [1]=>"string(8) "XWW-Origin" -Authenticate"]=> array(1) { [0]=> string(43) "Bearer realm="string(98) "AEnB2UqTiUNaUerDLJmk0bSt4RPckIW2zDyfsTrDCBrJjnSXUBvcVKTU80afct3DEHXIrhxrg5VE27lqL9N4rBN_P20ffirRdQ" } ["Vary"]=> array(2) { [0]=> string(6) "Origin" [1]=>"string(8) "XWW-Origin" -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

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Osin, 2018-10-10
@Junart1

"Authorization" } ], "code": 401, "message": "Login Required" } } "

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question