PHPackages                             andalisolutions/oauth2-anaf - 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. andalisolutions/oauth2-anaf

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

andalisolutions/oauth2-anaf
===========================

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

v1.0.0(2y ago)194.1k↓31.8%4[1 PRs](https://github.com/andalisolutions/oauth2-anaf/pulls)MITPHPPHP ^8.1.0

Since Dec 29Pushed 2y ago3 watchersCompare

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

READMEChangelog (2)Dependencies (6)Versions (4)Used By (0)

 [![OAuth 2.0 ANAF](https://raw.githubusercontent.com/andalisolutions/oauth2-anaf/main/art/social.png)](https://raw.githubusercontent.com/andalisolutions/oauth2-anaf/main/art/social.png)

 [![GitHub Workflow Status (main)](https://camo.githubusercontent.com/db670e21a19187bdbf26e53b3ea22ae39fe1c425943cb04c26caa0085e20504a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f616e64616c69736f6c7574696f6e732f6f61757468322d616e61662f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d726f756e642d737175617265)](https://github.com/andalisolutions/oauth2-anaf/actions) [![Total Downloads](https://camo.githubusercontent.com/b05dd26af6b049c8db7bc638cc36e636847f56b65d450733285a1d14804ad76f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616e64616c69736f6c7574696f6e732f6f61757468322d616e6166)](https://packagist.org/packages/andalisolutions/oauth2-anaf) [![Latest Version](https://camo.githubusercontent.com/54eb088c0f31240648e5fd9159f012d0c9b9fb4426083e5a6c0f50c0e7c7df13/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616e64616c69736f6c7574696f6e732f6f61757468322d616e6166)](https://packagist.org/packages/andalisolutions/oauth2-anaf) [![License](https://camo.githubusercontent.com/f733a3d9bf8597a490d479b4fb263a57e019fa2a4be4866c2f84b2e8410bd8cb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f616e64616c69736f6c7574696f6e732f6f61757468322d616e6166)](https://packagist.org/packages/andalisolutions/oauth2-anaf)

ANAF Provider for OAuth 2.0 Client
==================================

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

This package provides [ANAF OAuth 2.0](https://static.anaf.ro/static/10/Anaf/Informatii_R/API/Oauth_procedura_inregistrare_aplicatii_portal_ANAF.pdf) support for the PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client).

---

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

[](#installation)

To install, use composer:

```
composer require andalisolutions/oauth2-anaf

```

Usage
-----

[](#usage)

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

### Authorization Code Flow

[](#authorization-code-flow)

```
$provider = new Anaf\OAuth2\Client\Provider\AnafProvider(
    clientId: '{anaf-client-id}',
    clientSecret: '{anaf-client-secret}',
    redirectUrl: 'https://example.com/callback-url',
);

// Redirect to the authorization URL
$authorizationUrl = $provider->getAuthorizationUrl();
header('Location: ' . $authorizationUrl);

// This part will be in your callback script
if (isset($_GET['code'])) {
    try {
        $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') . "";

    } catch (Exception $e) {
        // Handle errors, such as an invalid code
    }
}
```

Testing
-------

[](#testing)

```
composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/thephpleague/oauth2-instagram/blob/master/CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Andrei Ciungulete](https://github.com/ciungulete)
- [All Contributors](https://github.com/andalisolutions/oauth2-anaf/contributors)

License
-------

[](#license)

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

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 62.5% 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.

###  Release Activity

Cadence

Every ~30 days

Total

2

Last Release

841d ago

Major Versions

v0.1.0 → v1.0.02024-01-28

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/742128?v=4)[Andrei Ciungulete](/maintainers/ciungulete)[@ciungulete](https://github.com/ciungulete)

---

Top Contributors

[![ciungulete](https://avatars.githubusercontent.com/u/742128?v=4)](https://github.com/ciungulete "ciungulete (5 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")

---

Tags

anafanaf-apiauthenticationauthorizationoauth2phpphpapiclientAuthenticationoauthoauth2authorizationanaf

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/andalisolutions-oauth2-anaf/health.svg)

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

###  Alternatives

[league/oauth2-google

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

42121.2M118](/packages/league-oauth2-google)[league/oauth2-facebook

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

32013.0M66](/packages/league-oauth2-facebook)

PHPackages © 2026

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