1. Go to this page and download the library: Download holyhabit/oauth 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/ */
holyhabit / oauth example snippets
use HolyOAuth\Core\OAuthManager;
use HolyOAuth\Providers\GoogleProvider;
use HolyOAuth\Storage\SessionStorage;
$storage = new SessionStorage();
$manager = new OAuthManager($storage);
$manager->registerProvider('google', GoogleProvider::create('client-id', 'secret', 'redirect-uri'));
// Login: header('Location: ' . $manager->getAuthorizationUrl('google'));
// Callback: $user = $manager->handleCallback('google', $_GET['code'], $_GET['state']);
HolyOAuth\Core\OAuthManager;
use HolyOAuth\Providers\GoogleProvider;
use HolyOAuth\Storage\SessionStorage;
use HolyOAuth\Security\StateManager;
// Initialize
$storage = new SessionStorage();
$stateManager = new StateManager($storage);
$oauthManager = new OAuthManager($storage, $stateManager);
// Configure Google OAuth
$googleProvider = GoogleProvider::create(
$_ENV['GOOGLE_CLIENT_ID'],
$_ENV['GOOGLE_CLIENT_SECRET'],
'http://localhost:8000/callback.php'
);
$oauthManager->registerProvider('google', $googleProvider);
// Start OAuth flow
$authUrl = $oauthManager->getAuthorizationUrl('google');
header('Location: ' . $authUrl);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.