mailium/oauth-client-php

Library for authenticating with Mailium Oauth Server

1.0.23 2018-12-11 11:32 UTC

This package is not auto-updated.

Last update: 2024-05-09 13:53:07 UTC


README

Latest Stable Version Monthly Downloads License Build Status

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();