David Bomba 9ff1817c1c Google Auth - Authenticate with backend server (API) (#1405)
* Google OAuth - Authentication with a backend server
2017-03-31 00:01:42 +11:00

24 lines
485 B
PHP

<?php namespace App\Ninja\OAuth\Providers;
class Google implements ProviderInterface
{
public function getTokenResponse($token)
{
$client = new \Google_Client(['client_id' => env('GOOGLE_CLIENT_ID','')]);
$payload = $client->verifyIdToken($token);
if ($payload)
return $this->harvestEmail($payload);
else
return null;
}
public function harvestEmail($payload)
{
return $payload['email'];
}
}