Authorize users with your application using multiple OAuth 1 and OAuth 2 providers.
OAuth is split into two sections, clients and providers. A client is an application - perhaps a basic Twitter feed aggregator - which authenticates with an OAuth provider, which in this example would be Twitter itself. You can interact with any provider which is supported in the list below:
In this example we will authenticate the user using Twitter.
$provider = \OAuth\OAuth::provider('Twitter', array(
'id' => 'CLIENT_ID',
'secret' => 'CLIENT_SECRET',
'redirect_url' => 'URL_TO_THIS_PAGE'
));
$oauth = $provider->process(function($url, $token = null) {
if ($token) {
session_start();
$_SESSION['token'] = base64_encode(serialize($token));
}
header("Location: {$url}");
exit;
}, function() {
session_start();
return unserialize(base64_decode($_SESSION['token']));
});
print_r($oauth->getUserInfo());
If all goes well you should see a dump of user data.
develop
branch (or branch off of it)