PHP Classes
elePHPant
Icontem

PHP OAuth2 Client: Authorize and access servers using OAuth2

Recommend this page to a friend!
  Info   View files Documentation   View files View files (75)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2019-05-06 (18 days ago) RSS 2.0 feedNot yet rated by the usersTotal: 77 This week: 7All time: 9,345 This week: 52Up
Version License PHP version Categories
client-oauth2 1.0.0MIT/X Consortium ...5PHP 5, User Management, Web services
Description Author

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.

  Performance   Level  
Name: Payam Naderi <contact>
Classes: 11 packages by
Country: Iran Iran
Age: 36
All time rank: 244239 in Iran Iran
Week rank: 31 Up1 in Iran Iran Up
Innovation award
Innovation award
Nominee: 2x

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

  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

  Files folder image Files  /  mod  
File Role Description
Files folder imageActions (3 files)
Files folder imageAuthenticate (3 files)
Files folder imageAuthenticator (1 file)
Files folder imageconfig (3 files, 1 directory)
Files folder imageServices (1 file, 2 directories)
  Plain text file Module.php Class Class source
  Accessible without login Plain text file _functions.php Example Example script

  Files folder image Files  /  mod  /  Actions  
File Role Description
  Plain text file AssertDebugTokenAction.php Class Class source
  Plain text file AssertTokenAction.php Class Class source
  Plain text file ServiceAssertTokenAction.php Class Class source

  Files folder image Files  /  mod  /  Authenticate  
File Role Description
  Plain text file IdentifierHttpToken.php Class Class source
  Plain text file IdentifierTokenAssertion.php Class Class source
  Plain text file IdentityOAuthToken.php Class Class source

  Files folder image Files  /  mod  /  Authenticator  
File Role Description
  Plain text file OAuthTokenAuthenticatorPlugin.php Class Class source

  Files folder image Files  /  mod  /  config  
File Role Description
Files folder imageoauth2client (3 files)
  Plain text file mod-oauth2client.actions.conf.php Class Class source
  Plain text file mod-oauth2client.conf.php Class Class source
  Plain text file mod-oauth2client.services.conf.php Class Class source

  Files folder image Files  /  mod  /  config  /  oauth2client  
File Role Description
  Accessible without login Plain text file client_credential.conf.php Aux. Auxiliary script
  Accessible without login Plain text file federation.conf.php Example Example script
  Plain text file token_assertion.conf.php Class Class source

  Files folder image Files  /  mod  /  Services  
File Role Description
Files folder imageAuthenticate (2 files)
Files folder imageAuthenticators (1 file)
  Plain text file ServiceOAuthClient.php Class Class source

  Files folder image Files  /  mod  /  Services  /  Authenticate  
File Role Description
  Plain text file IdentityProviderFederation.php Class Class source
  Plain text file ServiceIdentityProviderFederation.php Class Class source

  Files folder image Files  /  mod  /  Services  /  Authenticators  
File Role Description
  Plain text file ServiceAuthenticatorToken.php Class Class source

  Files folder image Files  /  src  
File Role Description
Files folder imageAssertion (3 files, 1 directory)
Files folder imageClient (3 files, 2 directories)
Files folder imageException (11 files)
Files folder imageFederation (1 file, 2 directories)
Files folder imageGrant (6 files, 2 directories)
Files folder imageInterfaces (5 files)
Files folder imageModel (1 directory)
  Plain text file Client.php Class Class source
  Plain text file Federation.php Class Class source
  Accessible without login Plain text file _functions.php Example Example script

  Files folder image Files  /  src  /  Assertion  
File Role Description
Files folder imageRemoteServer (1 file)
  Plain text file aAssertToken.php Class Class source
  Plain text file AssertByInternalServer.php Class Class source
  Plain text file AssertByRemoteServer.php Class Class source

  Files folder image Files  /  src  /  Assertion  /  RemoteServer  
File Role Description
  Plain text file GrantExtension.php Class Class source

  Files folder image Files  /  src  /  Client  
File Role Description
Files folder imageCommand (2 files)
Files folder imagePlatformRest (1 file)
  Plain text file aOAuthPlatform.php Class Class source
  Plain text file PlatformRest.php Class Class source
  Plain text file Response.php Class Class source

  Files folder image Files  /  src  /  Client  /  Command  
File Role Description
  Plain text file GetAuthorizeUrl.php Class Class source
  Plain text file Token.php Class Class source

  Files folder image Files  /  src  /  Client  /  PlatformRest  
File Role Description
  Plain text file ServerUrlEndpoints.php Class Class source

  Files folder image Files  /  src  /  Exception  
File Role Description
  Plain text file exIdentifierExists.php Class Class source
  Plain text file exInvalidRequest.php Class Class source
  Plain text file exMissingGrantRequestParams.php Class Class source
  Plain text file exOAuthAccessDenied.php Class Class source
  Plain text file exOAuthScopeRequired.php Class Class source
  Plain text file exPasswordNotMatch.php Class Class source
  Plain text file exResponseError.php Class Class source
  Plain text file exServerError.php Class Class source
  Plain text file exTokenMismatch.php Class Class source
  Plain text file exUnexpectedValue.php Class Class source
  Plain text file exUserNotFound.php Class Class source

  Files folder image Files  /  src  /  Federation  
File Role Description
Files folder imageCommand (4 files, 3 directories)
Files folder imageTokenProvider (2 files)
  Plain text file PlatformRest.php Class Class source

  Files folder image Files  /  src  /  Federation  /  Command  
File Role Description
Files folder imageMe (3 files)
Files folder imageMembers (3 files)
Files folder imageRecover (2 files)
  Plain text file AccountInfo.php Class Class source
  Plain text file ListAccountsInfo.php Class Class source
  Plain text file Register.php Class Class source
  Plain text file tTokenAware.php Class Class source

  Files folder image Files  /  src  /  Federation  /  Command  /  Me  
File Role Description
  Plain text file AccountInfo.php Class Class source
  Plain text file ChangeIdentity.php Class Class source
  Plain text file ChangePassword.php Class Class source

  Files folder image Files  /  src  /  Federation  /  Command  /  Members  
File Role Description
  Plain text file Exists.php Class Class source
  Plain text file ValidateUserIdentifier.php Class Class source
  Plain text file Whois.php Class Class source

  Files folder image Files  /  src  /  Federation  /  Command  /  Recover  
File Role Description
  Plain text file ResendCode.php Class Class source
  Plain text file Validate.php Class Class source

  Files folder image Files  /  src  /  Federation  /  TokenProvider  
File Role Description
  Plain text file TokenFromOAuthClient.php Class Class source
  Plain text file TokenInstanceFromOAuthClient.php Class Class source

  Files folder image Files  /  src  /  Grant  
File Role Description
Files folder imageContainer (1 file)
Files folder imageExtension (1 file)
  Plain text file aGrantRequest.php Class Class source
  Plain text file AuthorizeCode.php Class Class source
  Plain text file ClientCredential.php Class Class source
  Plain text file Implicit.php Class Class source
  Plain text file Password.php Class Class source
  Plain text file RefreshToken.php Class Class source

  Files folder image Files  /  src  /  Grant  /  Container  
File Role Description
  Plain text file GrantPlugins.php Class Class source

  Files folder image Files  /  src  /  Grant  /  Extension  
File Role Description
  Plain text file GrantSingleSignIn.php Class Class source

  Files folder image Files  /  src  /  Interfaces  
File Role Description
  Plain text file iAccessTokenEntity.php Class Class source
  Plain text file iClientOfOAuth.php Class Class source
  Plain text file iGrantAuthorizeRequest.php Class Class source
  Plain text file iGrantTokenRequest.php Class Class source
  Plain text file ipGrantRequest.php Class Class source

  Files folder image Files  /  src  /  Model  
File Role Description
Files folder imageEntity (1 file)

  Files folder image Files  /  src  /  Model  /  Entity  
File Role Description
  Plain text file AccessTokenEntity.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:77
This week:7
All time:9,345
This week:52Up