PHP code example of programster / google-sso
1. Go to this page and download the library: Download programster/google-sso library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
programster / google-sso example snippets
leSso = new GoogleSsoClient(
$myGoogleClientId,
$myGoogleClientSecret,
$myGoogleSsoCallbackUrl = "https://localhost",
new \GuzzleHttp\Psr7\HttpFactory(),
new \GuzzleHttp\Client(),
);
if (isset($_GET['code']))
{
// we are likely handling a user redirecting back here from having logged in with google.
$userData = $googleSso->handleGoogleSsoLogin();
print "Hello {$userData->getFullName()} with email address {$userData->getEmail()}";
}
else
{
$googleSso->sendUserToGoogleLogin();
}