staxxer / oauth2-moneybird
Moneybird OAuth 2.0 Client Provider for The PHP League OAuth2-Client
1.2.0
2026-02-20 15:40 UTC
Requires
- php: ^7.1 || >=8.0 <8.6
- league/oauth2-client: ^2.0
Requires (Dev)
- phpunit/phpunit: ^7.5.20 || ^8.5.21 || ^9.6 || ^10.5 || ^11.0
This package is not auto-updated.
Last update: 2026-05-02 15:05:56 UTC
README
This package provides Moneybird OAuth 2.0 support for the PHP League's OAuth 2.0 Client.
Installation
composer require staxxer/oauth2-moneybird
Usage
use Staxxer\OAuth2\Client\Provider\Moneybird; $provider = new Moneybird([ 'clientId' => '{moneybird-client-id}', 'clientSecret' => '{moneybird-client-secret}', 'redirectUri' => 'https://example.com/callback', ]);
Authorization
// Get authorization URL $authorizationUrl = $provider->getAuthorizationUrl(); // Store state for CSRF validation $_SESSION['oauth2state'] = $provider->getState(); // Redirect user header('Location: ' . $authorizationUrl);
Access Token
// After redirect back from Moneybird $token = $provider->getAccessToken('authorization_code', [ 'code' => $_GET['code'], ]); echo $token->getToken(); echo $token->getRefreshToken();
Refresh Token
$token = $provider->getAccessToken('refresh_token', [ 'refresh_token' => $existingToken->getRefreshToken(), ]);
Resource Owner (Administration)
$resourceOwner = $provider->getResourceOwner($token); // Administration ID echo $resourceOwner->getId(); // Administration name echo $resourceOwner->getName();
Testing
composer install vendor/bin/phpunit
License
MIT