richardhj/oauth2-newsletter2go

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

v2.0.1 2019-02-01 14:29 UTC

This package is auto-updated.

Last update: 2024-10-29 04:53:05 UTC


README

Latest Version on Packagist Software License Dependency Status

This package provides Newsletter2Go OAuth 2.0 support for the PHP League's OAuth 2.0 Client.

Install

Via Composer

$ composer require richardhj/oauth2-newsletter2go

Usage

Use the auth key from your Newsletter2Go account to initiate the provider.

$provider = new Richardhj\Newsletter2Go\OAuth2\Client\Provider\Newsletter2Go([
    'authKey' => $authKey,
]);

Then use your login credentials to fetch an AccessToken instance.

$accessToken = $provider->getAccessToken(
    'https://nl2go.com/jwt',
    [
        'username' => $username,
        'password' => $password,
    ]
);

Refreshing a token

Initiate the provider as described before. Then:

$accessToken = $provider->getAccessToken(
    'https://nl2go.com/jwt_refresh',
    [
        'refresh_token' => $accessToken->getRefreshToken()
    ]
);

It is recommended to save the refresh_token ($refreshToken = $accessToken->getRefreshToken()) in your application rather than the username and password. Nevertheless: Handle with care!

Visit the official API documentation for reference.

License

The GNU Lesser General Public License (LGPL).