2017 © Pedro Peláez
 

library client-oauth2

Provides a simple and clean Abstraction for Integration with OAuth 2.0 Server Providers.

image

poirot/client-oauth2

Provides a simple and clean Abstraction for Integration with OAuth 2.0 Server Providers.

  • Tuesday, May 29, 2018
  • by Payam
  • Repository
  • 2 Watchers
  • 0 Stars
  • 263 Installations
  • PHP
  • 5 Dependents
  • 2 Suggesters
  • 0 Forks
  • 2 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Client-OAuth2

Provides a simple and clean Abstraction for Integration with OAuth 2.0 Server Providers., (*1)

Config Client

$auth = new \Poirot\OAuth2Client\Client(
    'http://172.17.0.1:8000/'
    , 'test@default.axGEceVCtGqZAdW3rc34sqbvTASSTZxD'
    , 'xPWIpmzBK38MmDRd'
);

Retrieve Implicit Url Redirection

$url = $auth->attainAuthorizationUrl( $auth->withGrant('implicit') );

Authorization Code Grant

Retrieve Redirection To Authorize Url:, (*2)

$url = $auth->attainAuthorizationUrl( $auth->withGrant(GrantPlugins::AUTHORIZATION_CODE) );

When User redirect back include Auth Code:, (*3)

/** @var iAccessTokenObject $token */
$token = $auth->attainAccessToken(
    $auth->withGrant(GrantPlugins::AUTHORIZATION_CODE, ['code' => 'your_auth_code'])
);

$token->getAccessToken();
$token->getScopes();
$token->getDateTimeExpiration();
// ...

Client Credential Grant

override default scopes request, (*4)

$token = $auth->attainAccessToken(
    $auth->withGrant(GrantPlugins::CLIENT_CREDENTIALS, [ 'scopes' => ['override' ,'scopes'] ])
);

Password Credential

Specific Params Passed As Argument To Grant Factory, (*5)

try {
    $auth->attainAccessToken(
        $auth->withGrant('password')
    );
} catch (\Poirot\OAuth2Client\Exception\exMissingGrantRequestParams $e) {
    // Request Param "username" & "password" must Set.
    echo $e->getMessage();

    $token = $token = $auth->attainAccessToken(
        $auth->withGrant('password', ['username' => 'payam', 'password' => '123456'])
    );

    $refreshTokenStr = $token->getRefreshToken();
}

And So on ....

Poirot-OAuth2 Server Federation Commands

Specific Poirot Server Federation Commands To Deal 3rd party application with Server., (*6)

! For Federation Calls we need valid token: this token can strictly defined to client or retrieve from server., (*7)

example below show token asserted from oauth server when required!, (*8)


// Setup OAuth2 Client $client = new \Poirot\OAuth2Client\Client( 'http://172.17.0.1:8000/' , 'test@default.axGEceVCtGqZAdW3rc34sqbvTASSTZxD' , 'xPWIpmzBK38MmDRd' ); // Token Provider for Federation Calls // Use Credential Grant as Grant Type for Tokens $tokenProvider = new TokenFromOAuthClient( $client , $client->withGrant('client_credentials') ); // Note: // Make Calls and Don`t Worry About Token Renewal And Expired Tokens. // Platfrom Will Handle It. $federation = new \Poirot\OAuth2Client\Federation( 'http://172.17.0.1:8000/' , $tokenProvider ); // Check wheather this identifier(s) is given by any user? $checkExists = $federation->checkIdentifierGivenToAnyUser([ 'email' => 'naderi.payam@gmail.com', 'mobile' => [ 'number' => '9355497674', 'country' => '+98', ], ]);

The Versions

29/05 2018

dev-devel

dev-devel

Provides a simple and clean Abstraction for Integration with OAuth 2.0 Server Providers.

  Sources   Download

The Requires

 

by Payam Naderi

10/05 2017

dev-master

9999999-dev

Provides a simple and clean Abstraction for Integration with OAuth 2.0 Server Providers.

  Sources   Download

The Requires

 

by Payam Naderi