46 if (!isset(
$_GET[
'code']) && !isset(
$_GET[
'provider'])) {
49 <body>Select Provider:<br/>
50 <
a href=
'?provider=Google'>Google</
a><br/>
51 <
a href=
'?provider=Yahoo'>Yahoo</
a><br/>
52 <
a href=
'?provider=Microsoft'>Microsoft/Outlook/Hotmail/Live/Office365</
a><br/>
59 require
'vendor/autoload.php';
65 if (array_key_exists(
'provider',
$_GET)) {
68 } elseif (array_key_exists(
'provider',
$_SESSION)) {
71 if (!in_array(
$providerName, [
'Google',
'Microsoft',
'Yahoo'])) {
72 exit(
'Only Google, Microsoft and Yahoo OAuth2 providers are currently supported in this script.');
77 $clientId =
'RANDOMCHARS-----duv1n2.apps.googleusercontent.com';
88 'accessType' =>
'offline' 99 'https://mail.google.com/' 118 exit(
'Provider missing');
121 if (!isset(
$_GET[
'code'])) {
125 header(
'Location: ' . $authUrl);
131 exit(
'Invalid state');
136 'authorization_code',
138 'code' =>
$_GET[
'code']
143 echo 'Refresh Token: ',
$token->getRefreshToken();
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
Aliases for League Provider Classes Make sure you have added these to your composer.json and run composer install Plenty to choose from here:
if(array_key_exists('provider', $_GET)) elseif(array_key_exists('provider', $_SESSION)) if(!in_array($providerName, ['Google', 'Microsoft', 'Yahoo'])) $clientId
Get an OAuth2 token from an OAuth2 provider.