A Zend Framework 2 module to integrate oauth2-client and oauth1-client library from the thephpleague.
// in config/module.config.php
use HtLeagueOauthClientModule\Module;
return [
Module::CONFIG => [
'oauth2_clients' => [
'facebook' => [
'clientId' => 'XXXXXXXX',
'clientSecret' => 'XXXXXXXX',
'redirectUri' => 'https://your-registered-redirect-uri/',
],
],
],
];
$facebookProvider = $serviceLocator->get('HtLeagueOauthClientModule\Oauth2ClientManager')->get('facebook');
- Create a class implementing
League\OAuth2\Client\Provider\ProviderInterface
.
class MyProvider implements League\OAuth2\Client\Provider\ProviderInterface
{
// .....
}
- Inform Oauth2 client manager about the new provider
// in config/module.config.php
use HtLeagueOauthClientModule\Module;
return [
Module::CONFIG => [
'oauth2_client_manager' => [
'factories' => [
'my_provider' => 'MyProviderFactory',
],
],
],
];
- Use the provider
$myProvider = $serviceLocator->get('HtLeagueOauthClientModule\Oauth2ClientManager')->get('my_provider');
// in config/module.config.php
use HtLeagueOauthClientModule\Module;
return [
Module::CONFIG => [
'oauth1_clients' => [
'twitter' => [
'identifier' => 'your-identifier',
'secret' => 'your-secret',
'callback_uri' => 'http://your-callback-uri/',
],
],
],
];
$twitterProvider = $serviceLocator->get('HtLeagueOauthClientModule\Oauth1ClientManager')->get('twitter');
- Create a class extending
League\OAuth1\Client\Server\Server
.
class MyProvider extends League\OAuth1\Client\Server\Server
{
// .....
}
- Inform Oauth1 client manager about the new provider
// in config/module.config.php
use HtLeagueOauthClientModule\Module;
return [
Module::CONFIG => [
'oauth1_client_manager' => [
'factories' => [
'my_provider' => 'MyProviderFactory',
],
],
],
];
- Use the provider
$myProvider = $serviceLocator->get('HtLeagueOauthClientModule\Oauth1ClientManager')->get('my_provider');