dev-master
9999999-devAuthorize users in your application with multiple OAuth 2.0 providers
dbad-license
The Requires
- php >=5.3.0
- guzzle/guzzle 3.3.*
The Development Requires
by Chris Harvey
authentication authorization oauth providers
Wallogit.com
2017 © Pedro Peláez
Authorize users in your application with multiple OAuth 2.0 providers
Deprecated: Use league/oauth2-client., (*1)
Authorize users with your application using multiple OAuth 2 providers., (*2)
In this example we will authenticate the user using Facebook., (*3)
$oauth = new \OAuth2\Provider\Facebook(array(
'id' => 'CLIENT_ID',
'secret' => 'CLIENT_SECRET',
'redirect_url' => 'URL_TO_THIS_PAGE'
));
if ( ! $oauth->isAuthenticated()) {
header("Location: {$oauth->getAuthenticationUrl()}");
exit;
}
// Tokens
print_r($oauth->getUserTokens());
// User data
print_r($oauth->getUserInfo());
If all goes well you should see a dump of the users tokens and data., (*4)
You can also use this package to make calls to your respective APIs using Guzzle., (*5)
$client = new \OAuth2\Client('https://graph.facebook.com');
$client->setUserTokens($oauth->getUserTokens());
echo $client->get('me')->send();
This example should show your Facebook profile from the API along with the headers, (*6)
develop branch (or branch off of it)Authorize users in your application with multiple OAuth 2.0 providers
dbad-license
authentication authorization oauth providers