PHPackages                             mollie/oauth2-mollie-php - 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. mollie/oauth2-mollie-php

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

mollie/oauth2-mollie-php
========================

Mollie Provider for OAuth 2.0 Client

v2.9.0(5mo ago)251.7M↓39.2%151BSD-2-ClausePHPPHP ^7.4|^8.0CI passing

Since Nov 26Pushed 5mo ago36 watchersCompare

[ Source](https://github.com/mollie/oauth2-mollie-php)[ Packagist](https://packagist.org/packages/mollie/oauth2-mollie-php)[ Docs](https://github.com/mollie/oauth2-mollie-php)[ RSS](/packages/mollie-oauth2-mollie-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (22)Used By (1)

[![Mollie-Logo-Style-Small](https://private-user-images.githubusercontent.com/7265703/259761514-b20c8a7f-e145-4afd-bcec-23e7015aed6c.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyNjY5NTMsIm5iZiI6MTc3NTI2NjY1MywicGF0aCI6Ii83MjY1NzAzLzI1OTc2MTUxNC1iMjBjOGE3Zi1lMTQ1LTRhZmQtYmNlYy0yM2U3MDE1YWVkNmMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDQwNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA0MDRUMDEzNzMzWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZTIyMjg2NDkwZjgyMzRiZWY2MDc4Yzk1YWY4NjA5Nzk2NDZkODFiMzMxNGRmNDA4ZTg5NzExMzI4ZjY1NjEwMiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.BmbMikQnEroZlV5l9BKVF-CGy_sAa8tZIz6kvVz-lcY)](https://private-user-images.githubusercontent.com/7265703/259761514-b20c8a7f-e145-4afd-bcec-23e7015aed6c.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyNjY5NTMsIm5iZiI6MTc3NTI2NjY1MywicGF0aCI6Ii83MjY1NzAzLzI1OTc2MTUxNC1iMjBjOGE3Zi1lMTQ1LTRhZmQtYmNlYy0yM2U3MDE1YWVkNmMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDQwNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA0MDRUMDEzNzMzWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZTIyMjg2NDkwZjgyMzRiZWY2MDc4Yzk1YWY4NjA5Nzk2NDZkODFiMzMxNGRmNDA4ZTg5NzExMzI4ZjY1NjEwMiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.BmbMikQnEroZlV5l9BKVF-CGy_sAa8tZIz6kvVz-lcY)

Mollie Connect in PHP
=====================

[](#mollie-connect-in-php)

This package provides Mollie OAuth 2.0 support for the PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client). Visit our [API documentation](https://docs.mollie.com/connect/getting-started) for more information about the Mollie implementation of OAuth2.

Use Mollie Connect (OAuth) to easily connect Mollie Merchant accounts to your application. [Mollie Connect](https://docs.mollie.com/connect/overview) also makes it possible to charge additional fees to your costumers with [Application Fee](https://docs.mollie.com/connect/application-fees).

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

[](#installation)

By far the easiest way to install the Mollie API client is to require it with [Composer](http://getcomposer.org/doc/00-intro.md).

```
$ composer require mollie/oauth2-mollie-php ^2.0

    {
        "require": {
            "mollie/oauth2-mollie-php": "^2.0"
        }
    }

```

You may also git checkout or [download all the files](https://github.com/mollie/oauth2-mollie-php/archive/master.zip), and include the OAuth 2.0 provider manually.

Usage
-----

[](#usage)

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

### Authorization Code Flow

[](#authorization-code-flow)

```
$provider = new \Mollie\OAuth2\Client\Provider\Mollie([
    'clientId'     => 'YOUR_CLIENT_ID',
    'clientSecret' => 'YOUR_CLIENT_SECRET',
    'redirectUri'  => 'https://your-redirect-uri',
]);

// 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([
        // Optional, only use this if you want to ask for scopes the user previously denied.
        'approval_prompt' => 'force',

        // Optional, a list of scopes. Defaults to only 'organizations.read'.
        'scope' => [
	    \Mollie\OAuth2\Client\Provider\Mollie::SCOPE_ORGANIZATIONS_READ,
	    \Mollie\OAuth2\Client\Provider\Mollie::SCOPE_PAYMENTS_READ,
	],
    ]);

    // 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']) || ($_GET['state'] !== $_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']
        ]);

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

        print_r($resourceOwner->toArray());
    }
    catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e)
    {
        // Failed to get the access token or user details.
        exit($e->getMessage());
    }
}
```

### Refreshing A Token

[](#refreshing-a-token)

```
$provider = new \Mollie\OAuth2\Client\Provider\Mollie([
    'clientId'     => 'YOUR_CLIENT_ID',
    'clientSecret' => 'YOUR_CLIENT_SECRET',
    'redirectUri'  => 'https://your-redirect-uri',
]);

$grant = new \League\OAuth2\Client\Grant\RefreshToken();
$token = $provider->getAccessToken($grant, ['refresh_token' => $refreshToken]);
```

### Authenticating using the AccessToken (mollie-api-php example)

[](#authenticating-using-the-accesstoken-mollie-api-php-example)

After refreshing an AccessToken, here's how to use it with the [mollie-api-php package](https://www.github.com/mollie/mollie-api-php). Note that the `getToken()` method is used to obtain the access token string.

```
$mollie = new \Mollie\Api\MollieApiClient;
$mollie->setAccessToken($token->getToken());

// With the correct scopes, you can now interact with Mollie's API on behalf of the Merchant
$payments = $mollie->payments->page();
```

Note

In order to access the mollie api via `\Molie\Api\MollieApiClient`, the [mollie/mollie-api-php](github.com/mollie/mollie-api-php) library is required!

### Revoking a token

[](#revoking-a-token)

Both AccessTokens and RefreshTokens are revokable. Here's how to revoke an AccessToken:

```
$provider = new \Mollie\OAuth2\Client\Provider\Mollie([
    'clientId'     => 'YOUR_CLIENT_ID',
    'clientSecret' => 'YOUR_CLIENT_SECRET',
    'redirectUri'  => 'https://your-redirect-uri',
]);

$provider->revokeAccessToken($accessToken->getToken());
```

Similarly, here's how to revoke a RefreshToken:

**Note: When you revoke a refresh token, all access tokens based on the same authorization grant will be revoked as well.**

```
$provider = new \Mollie\OAuth2\Client\Provider\Mollie([
    'clientId'     => 'YOUR_CLIENT_ID',
    'clientSecret' => 'YOUR_CLIENT_SECRET',
    'redirectUri'  => 'https://your-redirect-uri',****
]);

$provider->revokeRefreshToken($refreshToken->getToken());
```

API documentation
-----------------

[](#api-documentation)

If you wish to learn more about our APIs, please visit the [Mollie Developer Portal](https://www.mollie.com/en/developers).

Want to help us make our API client even better?
------------------------------------------------

[](#want-to-help-us-make-our-api-client-even-better)

Want to help us make our API client even better? We take [pull requests](https://github.com/mollie/mollie-api-php/pulls?utf8=%E2%9C%93&q=is%3Apr), sure. But how would you like to contribute to a [technology oriented organization](https://www.mollie.com/nl/blog/post/werken-bij-mollie-sfeer-kansen-en-mogelijkheden/)? Mollie is hiring developers and system engineers. [Check out our vacancies](https://www.mollie.com/nl/jobs) or [get in touch](mailto:personeel@mollie.com).

License
-------

[](#license)

[BSD (Berkeley Software Distribution) License](http://www.opensource.org/licenses/bsd-license.php). Copyright (c) 2015-2018, Mollie B.V.

Support
-------

[](#support)

Contact: [www.mollie.com](https://www.mollie.com) —  — +31 20-612 88 55

- [More information about Mollie Connect](https://www.mollie.com/en/connect/)

###  Health Score

61

—

FairBetter than 99% of packages

Maintenance70

Regular maintenance activity

Popularity52

Moderate usage in the ecosystem

Community33

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~203 days

Recently: every ~118 days

Total

19

Last Release

169d ago

Major Versions

v1.0.5 → v2.0.02018-06-25

PHP version history (4 changes)1.0.0PHP &gt;=5.5.0

v2.0.0PHP &gt;=5.6.0

v2.5.0PHP &gt;=7.4.0

v2.8.0PHP ^7.4|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/23d4c374cd27da6bed534538eb3514a06d2c15485e9d63a8991b277909ecfca8?d=identicon)[willemmollie](/maintainers/willemmollie)

![](https://www.gravatar.com/avatar/dabb609ac7cf4f097fb06aa0f774363ab1cd044cb785f154466564027bd46646?d=identicon)[lvgunst](/maintainers/lvgunst)

![](https://www.gravatar.com/avatar/945b9f760957f60f6f8e1704a70d419f6846017da6b7e1e7f51c5111c9d920b0?d=identicon)[Daanvm](/maintainers/Daanvm)

![](https://avatars.githubusercontent.com/u/6184158?v=4)[Robbert Schreuder Hes](/maintainers/mollierobbert)[@mollierobbert](https://github.com/mollierobbert)

![](https://www.gravatar.com/avatar/0db6d714561c942dd2d7f9f97bd7543886d7bfdd61372b594b2312850fd99f2c?d=identicon)[molops](/maintainers/molops)

---

Top Contributors

[![sandervanhooft](https://avatars.githubusercontent.com/u/7265703?v=4)](https://github.com/sandervanhooft "sandervanhooft (26 commits)")[![Naoray](https://avatars.githubusercontent.com/u/10154100?v=4)](https://github.com/Naoray "Naoray (17 commits)")[![adriaanmol](https://avatars.githubusercontent.com/u/2109817?v=4)](https://github.com/adriaanmol "adriaanmol (8 commits)")[![mollierobbert](https://avatars.githubusercontent.com/u/6184158?v=4)](https://github.com/mollierobbert "mollierobbert (4 commits)")[![roydejong](https://avatars.githubusercontent.com/u/6772638?v=4)](https://github.com/roydejong "roydejong (4 commits)")[![holtkamp](https://avatars.githubusercontent.com/u/776405?v=4)](https://github.com/holtkamp "holtkamp (3 commits)")[![vernondegoede](https://avatars.githubusercontent.com/u/2484832?v=4)](https://github.com/vernondegoede "vernondegoede (2 commits)")[![ricardodevries](https://avatars.githubusercontent.com/u/78354174?v=4)](https://github.com/ricardodevries "ricardodevries (2 commits)")[![SanderVanLeeuwen](https://avatars.githubusercontent.com/u/1685007?v=4)](https://github.com/SanderVanLeeuwen "SanderVanLeeuwen (2 commits)")[![mweghorst](https://avatars.githubusercontent.com/u/9582326?v=4)](https://github.com/mweghorst "mweghorst (1 commits)")[![erikkraijenoord](https://avatars.githubusercontent.com/u/102791038?v=4)](https://github.com/erikkraijenoord "erikkraijenoord (1 commits)")[![ChristianVermeulen](https://avatars.githubusercontent.com/u/1062751?v=4)](https://github.com/ChristianVermeulen "ChristianVermeulen (1 commits)")[![ShortlyMAB](https://avatars.githubusercontent.com/u/4995979?v=4)](https://github.com/ShortlyMAB "ShortlyMAB (1 commits)")[![tomcoonen](https://avatars.githubusercontent.com/u/988013?v=4)](https://github.com/tomcoonen "tomcoonen (1 commits)")[![RickWong](https://avatars.githubusercontent.com/u/40102?v=4)](https://github.com/RickWong "RickWong (1 commits)")

---

Tags

apiclientserviceoauthoauth2authorizationauthorisationpaymentpaymentsgatewaypaypalidealmolliepaysafecardsepacreditcardsofortdirect debitmistercashbancontactsofortbankingbanktransferbelfiusbelfius direct netrefunds

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mollie-oauth2-mollie-php/health.svg)

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

###  Alternatives

[mollie/mollie-api-php

Mollie API client library for PHP. Mollie is a European Payment Service provider and offers international payment methods such as Mastercard, VISA, American Express and PayPal, and local payment methods such as iDEAL, Bancontact, SOFORT Banking, SEPA direct debit, Belfius Direct Net, KBC Payment Button and various gift cards such as Podiumcadeaukaart and fashioncheque.

60014.4M62](/packages/mollie-mollie-api-php)[mollie/laravel-mollie

Mollie API client wrapper for Laravel &amp; Mollie Connect provider for Laravel Socialite

3624.1M28](/packages/mollie-laravel-mollie)[mollie/magento2

Mollie Payment Module for Magento 2

1121.6M10](/packages/mollie-magento2)[mollie/magento

iDEAL, Creditcard, Bancontact/Mister Cash, SOFORT, Bank transfer, Bitcoin, PayPal &amp; paysafecard for Magento https://www.mollie.com/

397.9k](/packages/mollie-magento)[stevenmaguire/oauth2-keycloak

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

2275.9M27](/packages/stevenmaguire-oauth2-keycloak)[patrickbussmann/oauth2-apple

Sign in with Apple OAuth 2.0 Client Provider for The PHP League OAuth2-Client

1132.5M6](/packages/patrickbussmann-oauth2-apple)

PHPackages © 2026

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