PHPackages                             dyweb/oauth2-jaccount - 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. dyweb/oauth2-jaccount

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

dyweb/oauth2-jaccount
=====================

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

9121PHP

Since May 16Pushed 7y ago1 watchersCompare

[ Source](https://github.com/dyweb/oauth2-jaccount)[ Packagist](https://packagist.org/packages/dyweb/oauth2-jaccount)[ RSS](/packages/dyweb-oauth2-jaccount/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

JAccount Provider for OAuth 2.0 Client
======================================

[](#jaccount-provider-for-oauth-20-client)

This package provides JAccount OAuth 2.0 support for the PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client).

Installation
------------

[](#installation)

```
composer require dyweb/oauth2-jaccount

```

Usage
-----

[](#usage)

```
$provider = new \Dyweb\OAuth2\Client\Provider\JAccount([
    'clientId'                => 'yourId',          // The client ID assigned to you by NIC
    'clientSecret'            => 'yourSecret',      // The client password assigned to you by NIC
    'redirectUri'             => 'yourUrl'          // The return URL you specified for your app on NIC
]);

// If we don't have an authorization code then get one
if (!isset($_GET['code'])) {

    // Fetch the authorization URL from the provider; this returns the
    // urlAuthorize option and generates and applies any necessary parameters
    // (e.g. state).
    $authorizationUrl = $provider->getAuthorizationUrl();

    // Get the state generated for you and store it to the session.
    $_SESSION['oauth2state'] = $provider->getState();

    // Redirect the user to the authorization URL.
    header('Location: ' . $authorizationUrl);
    exit;

// Check given state against previously stored one to mitigate CSRF attack
} elseif (empty($_GET['state']) || (isset($_SESSION['oauth2state']) && $_GET['state'] !== $_SESSION['oauth2state'])) {

    if (isset($_SESSION['oauth2state'])) {
        unset($_SESSION['oauth2state']);
    }

    exit('Invalid state');

} else {

    try {

        // Try to get an access token using the authorization code grant.
        $accessToken = $provider->getAccessToken('authorization_code', [
            'code' => $_GET['code']
        ]);

        // We have an access token, which we may use in authenticated
        // requests against the service provider's API.
        echo 'Access Token: ' . $accessToken->getToken() . "";
        echo 'Refresh Token: ' . $accessToken->getRefreshToken() . "";
        echo 'Expired in: ' . $accessToken->getExpires() . "";
        echo 'Already expired? ' . ($accessToken->hasExpired() ? 'expired' : 'not expired') . "";

        // Using the access token, we may look up details about the
        // resource owner.
        $resourceOwner = $provider->getResourceOwner($accessToken);

        var_export($resourceOwner->toArray());

    } catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) {

        // Failed to get the access token or user details.
        exit($e->getMessage());

    }

}
```

For more information see the PHP League's general usage examples.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/michaelKaefer/oauth2-amazon/blob/master/LICENSE) for more information.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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/3fa57c39e87a0dce3efaca530092d08e27382e19ffc9e102dcd2a5bb281708d2?d=identicon)[at15](/maintainers/at15)

![](https://www.gravatar.com/avatar/8709729cfa7fd1650335a18ff524f148ae962020d877bd6d7f88c390b227ce42?d=identicon)[hebingchang](/maintainers/hebingchang)

---

Top Contributors

[![hebingchang](https://avatars.githubusercontent.com/u/7235968?v=4)](https://github.com/hebingchang "hebingchang (8 commits)")

---

Tags

jaccountoauth2sjtu

### Embed Badge

![Health badge](/badges/dyweb-oauth2-jaccount/health.svg)

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

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

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