PHPackages                             poirot/client-oauth2 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. poirot/client-oauth2

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

poirot/client-oauth2
====================

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

2309[2 issues](https://github.com/phPoirot/Client-OAuth2/issues)PHP

Since May 10Pushed 7y ago3 watchersCompare

[ Source](https://github.com/phPoirot/Client-OAuth2)[ Packagist](https://packagist.org/packages/poirot/client-oauth2)[ RSS](/packages/poirot-client-oauth2/feed)WikiDiscussions devel Synced 2w ago

READMEChangelogDependenciesVersions (2)Used By (0)

Client-OAuth2
=============

[](#client-oauth2)

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

Config Client
-------------

[](#config-client)

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

Retrieve Implicit Url Redirection
---------------------------------

[](#retrieve-implicit-url-redirection)

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

Authorization Code Grant
------------------------

[](#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
-----------------------

[](#client-credential-grant)

override default scopes request

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

Password Credential
-------------------

[](#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 ....
--------------

[](#and-so-on-)

Poirot-OAuth2 Server Federation Commands
========================================

[](#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',
    ],
]);
```

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 99.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/1f784f9dfb58e36b6a876f3057e5664bb904af71d30bb2023583118138dffe9a?d=identicon)[Payam](/maintainers/Payam)

---

Top Contributors

[![E1101](https://avatars.githubusercontent.com/u/427575?v=4)](https://github.com/E1101 "E1101 (113 commits)")[![MHHedayati](https://avatars.githubusercontent.com/u/12061683?v=4)](https://github.com/MHHedayati "MHHedayati (1 commits)")

---

Tags

oauth2oauth2-client

### Embed Badge

![Health badge](/badges/poirot-client-oauth2/health.svg)

```
[![Health](https://phpackages.com/badges/poirot-client-oauth2/health.svg)](https://phpackages.com/packages/poirot-client-oauth2)
```

###  Alternatives

[kartik-v/yii2-password

Useful password strength validation utilities for Yii Framework 2.0

761.2M17](/packages/kartik-v-yii2-password)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
