2017 © Pedro Peláez
 

library oauth2-simple-client

A simply better OAuth2 Client

image

stuki/oauth2-simple-client

A simply better OAuth2 Client

  • Sunday, December 21, 2014
  • by tom_anderson
  • Repository
  • 1 Watchers
  • 1 Stars
  • 66 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 519 Forks
  • 1 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

OAuth2 Simple Client

Build Status Coverage Status Total Downloads, (*1)

This OAuth2 client is a simply better way to use OAuth2 in your application., (*2)

Included Providers

  • Box
  • Eventbrite
  • Facebook
  • Github
  • Google
  • Instagram
  • LinkedIn
  • Meetup
  • Microsoft

About

This is a hard fork of ThePHPLeague/oauth-client and this is the offical repository for StukiOrg/oauth2-simple-client., (*3)

This simple client implements a well architected solution for OAuth2 authentication. Contributions are accepted for new OAuth2 adapters if you choose to share., (*4)

Installation

$ php composer.phar require stuki/oauth2-simple-client dev-master

ZF2 Example

use Stuki\OAuth2\Client;

    public function LoginAction()
    {
        $config = $this->getServiceLocator()->get('Config');

        $provider = new Client\Provider\Meetup(array(
            'clientId' => $config['meetup']['key'],
            'clientSecret' => $config['meetup']['secret'],
            'redirectUri' => $config['meetup']['redirect'],
        ));

        if ( ! $this->params()->fromQuery('code')) {
            // No authorization code; send user to get one
            // Some providers support and/or require an application state token
            return $this->plugin('redirect')->toUrl($provider->getAuthorizationUrl(array('state' => 'token')));
        } else {
            try {
                // Get an authorization token
                $token = $provider->getAccessToken('authorization_code', [
                    'code' => $_GET['code'],
                ]);
            } catch (Client\Exception\IDPException $e) {
                // Handle error from oauth2 server
            }

            // Store the access and refresh token for future use
            $container = new Container('oauth2');
            $container->accessToken = $token->accessToken;
            $container->refreshToken = $token->refreshToken;

            // Redirect to save session
            return $this->plugin('redirect')->toRoute('member');
        }
    }

Refresh a Token

use Stuki\OAuth2\Client;

$provider = new Client\Provider\<ProviderName>(array(
    'clientId'  =>  'id',
    'clientSecret'  =>  'secret',
    'redirectUri'   =>  'https://your-registered-redirect-uri/'
));

$grant = new Client\Grant\RefreshToken();
$token = $provider->getAccessToken($grant, ['refresh_token' => $refreshToken]);

The Versions

21/12 2014

dev-master

9999999-dev

A simply better OAuth2 Client

  Sources   Download

MIT

The Requires

 

The Development Requires

easy oauth2 simple oauth client

15/12 2014

1.0.x-dev

1.0.9999999.9999999-dev

OAuth 2.0 Client Library

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth sso oauth2 identity idp single sign on

03/12 2014

0.6.0

0.6.0.0

OAuth 2.0 Client Library

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth sso oauth2 identity idp single sign on

28/11 2014

0.5.0

0.5.0.0

OAuth 2.0 Client Library

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth sso oauth2 identity idp single sign on

20/10 2014

0.4.0

0.4.0.0

OAuth 2.0 Client Library

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth sso oauth2 identity idp single sign on

26/04 2014

0.3.0

0.3.0.0

OAuth 2.0 Client Library

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth sso oauth2 identity idp single sign on

25/03 2013

0.1

0.1.0.0 https://github.com/lncd/OAuth2-Client

OAuth 2.0 Client Library

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth sso oauth2 identity idp single sign on