staxxer/oauth2-moneybird

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

Maintainers

Package info

github.com/marketphase/oauth2-moneybird

pkg:composer/staxxer/oauth2-moneybird

Statistics

Installs: 1 212

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.2.0 2026-02-20 15:40 UTC

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