2017 © Pedro Peláez
 

library oauth2-human

Human OAuth 2.0 support for the PHP League's OAuth 2.0 Client

image

indibeast/oauth2-human

Human OAuth 2.0 support for the PHP League's OAuth 2.0 Client

  • Tuesday, February 9, 2016
  • by indibeast
  • Repository
  • 1 Watchers
  • 1 Stars
  • 48 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 4 % Grown

The README.md

Human Provider for OAuth 2.0 Client

Build Status, (*1)

This package provides Human OAuth 2.0 support for the PHP League's OAuth 2.0 Client., (*2)

Usage

Authorization Code Flow

$provider = new \Human\OAuth2\Client\Provider\Human([
    'clientId'      => 'XXXXXXXX',
    'clientSecret'  => 'XXXXXXXX',
    'redirectUri'   => 'https://your-registered-redirect-uri/',
    'account'       => 'XXXXX'

]);

if (!isset($_GET['code'])) {

    $authurl = $provider->getAuthorizationUrl();
    $_SESSION['oauth2state'] = $provider->getState();
    header('Location: '.$authUrl);
    exit;

 } elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])){

    unset($_SESSION['oauth2state']);
    exit('Invalid state');

 } else {

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

     try {

        $client = new Client($token);
        $user   = $client->getResourceOwner();
        echo $user->getFirstName();

     } catch (Exception $e) {

        echo "Oops!..."
     }

 }

License

The MIT License (MIT). Please see License File for more information., (*3)

The Versions

09/02 2016

dev-master

9999999-dev

Human OAuth 2.0 support for the PHP League's OAuth 2.0 Client

  Sources   Download

MIT

The Requires

 

The Development Requires

by Indika Gunasekara

authentication authorization oauth client oauth2 human