github AOuth2

_config.php

<?php
require_once './vendor/autoload.php';
session_start();
$github_keys = require('./github-app-keys.php');
$provider = new League\OAuth2\Client\Provider\Github(&#91;
	'clientId' 		=> $github_keys['clientId'],
	'clientSecret'	=> $github_keys['clientSecret'],
]);

$title = "PHP GitHub Login Sample";

github-app-keys.php

<?php
return &#91;
	'clientId' => 'xxxx',
	'clientSecret' => 'xxxxxxxx'
];

login.php

<?php
require_once '_config.php';

$authUrl = $provider->getAuthorizationUrl();

$_SESSION['oauth2state'] = $provider->getState();

header('Location: '.$authUrl);
exit;

callback.php

<?php
require_once '_config.php';

if (empty($_GET&#91;'state'&#93;) || ($_GET&#91;'state'&#93; !== $_SESSION&#91;'oauth2state'&#93;)){
	unset($_SESSION&#91;'oauth2state'&#93;);
	exit('Invalid state');
}

$token = $provider->getAccessToken('authorization_code', [
	'code' => $_GET['code']
]);

echo $token.'\n';
echo 'Successfully callbacked!!'.'\n';

$user = $provider->getResourceOwner($token);

echo '<pre>';
var_dump($user);
echo '</pre>';
[vagrant@localhost api]$ php -S 192.168.33.10:8000