PHP Classes
elePHPant
Icontem

PHP OAuth2 Client: Authorize and access servers using OAuth2

Recommend this page to a friend!

  Author Author  
Name: Payam Naderi <contact>
Classes: 10 packages by
Country: Iran Iran
Innovation award
Innovation award
Nominee: 2x


  Detailed description   Download Download .zip .tar.gz  
This package can authorize and access servers using OAuth2.

It can access given OAuth 2.0 servers supporting several methods to obtain tokens to access OAuth 2.0 servers like AUTHORIZATION_CODE and CLIENT_CREDENTIALS.

Subclasses of the client classes can make calls to specific OAuth 2.0 server APIs using the tokens obtained previous.

Details

Client-OAuth2

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

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:

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

When User redirect back include Auth Code:

/ @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

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

Password Credential

Specific Params Passed As Argument To Grant Factory

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.

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

example below show token asserted from oauth server when required!


// 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',
    ],
]);


  Classes of Payam Naderi  >  PHP OAuth2 Client  >  Download Download .zip .tar.gz  >  Support forum Support forum  >  Blog Blog  >  RSS 1.0 feed RSS 2.0 feed Latest changes  
Name: PHP OAuth2 Client
Base name: client-oauth2
Description: Authorize and access servers using OAuth2
Version: -
PHP version: 5
License: MIT/X Consortium License
 
  Groups   Applications   Files Files  

  Groups  
Group folder image PHP 5 Classes using PHP 5 specific features View top rated classes
Group folder image User Management User records, authentication and session handling View top rated classes
Group folder image Web services Web data clipping, SOAP or XML-RPC clients and servers View top rated classes


  Applications that use this package  
No pages of applications that use this class were specified.

Add link image If you know an application of this package, send a message to the author to add a link here.

  Files folder image Files  
File Role Description
Files folder imagemod (2 files, 5 directories)
Files folder imagesrc (3 files, 7 directories)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

Download Download all files: client-oauth2.tar.gz client-oauth2.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.