PHPackages                             therezor/oauth2-nbu-bankid - 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. therezor/oauth2-nbu-bankid

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

therezor/oauth2-nbu-bankid
==========================

National Bank of Ukraine OAuth 2.0 Client Provider for The PHP League OAuth2-Client

21161PHP

Since Mar 1Pushed 5y ago2 watchersCompare

[ Source](https://github.com/therezor/oauth2-nbu-bankid)[ Packagist](https://packagist.org/packages/therezor/oauth2-nbu-bankid)[ RSS](/packages/therezor-oauth2-nbu-bankid/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

NBU BankID Provider for OAuth 2.0 Client
========================================

[](#nbu-bankid-provider-for-oauth-20-client)

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

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

[](#installation)

1. Download and install eusphpe php extension
    Download link:
    For installation instructions read documentation inside installation archive (Documentation/EUSignPHPDescription.doc)
2. Add certificates to folder determined in step 1

3. Add php library to your project using composer:

```
composer require therezor/oauth2-nbu-bankid

```

Have fun....

Usage
-----

[](#usage)

Usage is the same as The League's OAuth client, using `\TheRezor\OAuth2\Client\Provider\BankID` as the provider.

### Authorization Code Flow

[](#authorization-code-flow)

```
$provider = new TheRezor\OAuth2\Client\Provider\BankID([
                        'clientId'     => '{your-client-id}',
                        'clientSecret' => '{your-client-secret}',
                        'redirectUri'  => 'https://example.com/callback-url',
                        'host'         => 'https://id.bank.gov.ua', // Optional, defaults to https://id.bank.gov.ua, for testing use https://testid.bank.gov.ua
                        'cert'         => file_get_contents('your_path/cert.cer'),
                        'key'          => file_get_contents('your_path/Key-6.dat'),
                        'password'     => '{your-private-key-password}',
                    ]);

if (!isset($_GET['code'])) {

    // If we don't have an authorization code then get one
    $authUrl = $provider->getAuthorizationUrl();
    $_SESSION['oauth2state'] = $provider->getState();
    header('Location: '.$authUrl);
    exit;

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

    unset($_SESSION['oauth2state']);
    exit('Invalid state');

} else {

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

    // Optional: Now you have a token you can look up a users profile data
    try {

        // We got an access token, let's now get the user's details
        $user = $provider->getResourceOwner($token);

        // Use these details to create a new profile
        echo("Hello {$user->getFirstName()} {$user->getLastName()}");
    } catch (Exception $e) {

        // Failed to get user details
        exit('Oh dear...');
    }

    // Use this to interact with an API on the users behalf
    echo $token->getToken();
}
```

Testing
-------

[](#testing)

Not available for now. TODO: add tests.

License
-------

[](#license)

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

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity30

Early-stage or recently created project

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/8a739d178a361305e697f551f836ea1cc05aa3bfceb017081129c748d0dd04df?d=identicon)[therezor](/maintainers/therezor)

### Embed Badge

![Health badge](/badges/therezor-oauth2-nbu-bankid/health.svg)

```
[![Health](https://phpackages.com/badges/therezor-oauth2-nbu-bankid/health.svg)](https://phpackages.com/packages/therezor-oauth2-nbu-bankid)
```

###  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)
