mardi 27 février 2018

Google OAuth error with Google+

I do some work with the Google OAuth Login and the Google+ API. I dont know, what I'am doing wrong, but there is a long error message displayed, when I'm running the script via PHP. First I show you the procedure. The User comes from the OAuth Login. Google send the authorization code to my Login.php script:

<?php
session_start();
include('g_client.php');
if(isset($_GET['code'])){

$client->authenticate($_GET['code']);
$_SESSION['access_token'] = $client->getAccessToken();
$_SESSION['EINGELOGGT'] = true;
$_SESSION['code'] = $_GET['code'];


header("Location: ./index.php");
}
else{
    echo "Fehler beim einloggen.";
}
?>
Then the script hand off to my index.php, where I request to the Google+ API:
include("g_client.php");
$plus = new Google_Service_Plus($client);
$_SESSION['access_token'] = $client->getAccessToken();

$me = $plus->people->get('me');
$name =  $me['displayName'];  

The g_client.php are the contain SECRETS and SCOPES:

include("../geheim.php");
require_once __DIR__.'/../vendor/autoload.php';

$client = new Google_Client();
$client->setClientId(CLIENT_ID);
$client->setClientSecret(CLIENT_SECRET);
$client->setRedirectUri(REDIRECT_URI);
$client->setIncludeGrantedScopes(true);

$client->setScopes('https://www.googleapis.com/auth/userinfo.profile');
$client->setScopes('https://www.googleapis.com/auth/userinfo.email');
$client->setScopes('https://www.googleapis.com/auth/plus.me');  

So, it should work in my view, but then there is the error message:

<b>Fatal error</b>: Uncaught exception 'Google_Service_Exception' with message '{&quot;error&quot;: {&quot;errors&quot;: [{&quot;domain&quot;: &quot;usageLimits&quot;,&quot;reason&quot;: &quot;dailyLimitExceededUnreg&quot;,&quot;message&quot;: &quot;Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.&quot;,&quot;extendedHelp&quot;: &quot;https://code.google.com/apis/console&quot;}],&quot;code&quot;: 403,&quot;message&quot;: &quot;Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.&quot;}}' in /srv/dev-disk-by-label-MAIN1/WEB_MAIN/Projekt1/vendor/google/apiclient/src/Google/Http/REST.php:118Stack trace:#0 /srv/dev-disk-by-label-MAIN1/WEB_MAIN/Projekt1/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 /srv/dev-disk-by-label-MAIN1/WEB_MAIN/Projekt1/vendor/google/apiclient/src/Google/Task/Runner.php(17 in <b>/srv/dev-disk-by-label-MAIN1/WEB_MAIN/Projekt1/vendor/google/apiclient/src/Google/Http/REST.php</b> on line <b>118</b><br />

I hope you can help me! Thank you!




Aucun commentaire:

Enregistrer un commentaire