mailium / oauth-client-php
Library for authenticating with Mailium Oauth Server
1.0.23
2018-12-11 11:32 UTC
Requires
- php: >=5.5.9
- guzzlehttp/guzzle: ^6.2
- monolog/monolog: ^1.19
Requires (Dev)
- phpunit/phpunit: ~4.0|~5.0
This package is not auto-updated.
Last update: 2024-11-21 16:06:12 UTC
README
Mailium Oauth Client provides easy to use wrappers for authorizing your application and getting the tokens required to talk to the API.
Example application
An example application can be found under example directory.
This is a simple working application that utilizes most of the features of the client.
Quick Start
First, let's install the library with composer:
composer require mailium/oauth-client-php
Initialize the client with your client_id and client_secret
$oauthClient = new MailiumOauthClient(); $oauthClient->setClientID("YOUR_CLIENT_ID"); $oauthClient->setClientSecret("YOUR_CLIENT_SECRET"); $oauthClient->setRedirectUri("YOUR_REDIRECT_URI"); // Scopes that your application need $oauthClient->addScope(MailiumOauthClient::SCOPE_BASIC); $oauthClient->addScope(MailiumOauthClient::SCOPE_CAMPAIGN_READ); $oauthClient->addScope(MailiumOauthClient::SCOPE_SUBSCRIBER_LIST_READ); // Set the callback method to store the oauth token $oauthClient->setTokenStoreCallbackFunction("storeToken");
Creating authorization URL
$authorizationUrl = $oauthClient->createAuthorizationUrl();
Getting the tokens after receiving the authorization code
$oauthClient->authorize($authorizationCode);
Getting Resource Owner
$oauthClient->getResourceOwner();