PHPackages                             antevenio/mdirector-oauth-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. antevenio/mdirector-oauth-client

ActiveLibrary

antevenio/mdirector-oauth-client
================================

Oauth client library specific to access mdirector api services

1.0.0(6y ago)1111MITPHPCI failing

Since Nov 6Pushed 6mo ago4 watchersCompare

[ Source](https://github.com/Antevenio/oauth2-mdirector)[ Packagist](https://packagist.org/packages/antevenio/mdirector-oauth-client)[ RSS](/packages/antevenio-mdirector-oauth-client/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (6)Versions (12)Used By (0)

oauth2-mdirector
================

[](#oauth2-mdirector)

[![Latest Stable Version](https://camo.githubusercontent.com/e2a2546cc9c3510daf53a8bd122587363d5d7f5f1376ea638288d74e3878fe28/68747470733a2f2f706f7365722e707567782e6f72672f616e746576656e696f2f6f61757468322d6d6469726563746f722f762f737461626c65)](https://packagist.org/packages/antevenio/oauth2-mdirector)[![Total Downloads](https://camo.githubusercontent.com/920e8dde4ccf23f125a1bfd7a9d7ab10303c9d1584d237f7e8fb6bfff32bd128/68747470733a2f2f706f7365722e707567782e6f72672f616e746576656e696f2f6f61757468322d6d6469726563746f722f646f776e6c6f616473)](https://packagist.org/packages/antevenio/oauth2-mdirector)[![License](https://camo.githubusercontent.com/77034cadf0237471c67067cbd7d74b0c8a758703c7702ad927befdaf7a6823a3/68747470733a2f2f706f7365722e707567782e6f72672f616e746576656e696f2f6f61757468322d6d6469726563746f722f6c6963656e7365)](https://packagist.org/packages/antevenio/oauth2-mdirector)[![Travis build](https://camo.githubusercontent.com/af0dabe7897e70d6717bee09fae997e2770fda27cff3aa1fe4044ac859b12492/68747470733a2f2f6170692e7472617669732d63692e6f72672f416e746576656e696f2f6f61757468322d6d6469726563746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Antevenio/oauth2-mdirector)[![Coverage Status](https://camo.githubusercontent.com/2488b709209bf423926c21a0c4f37ede8be2dda7489233ce9f03980043869f9b/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f416e746576656e696f2f6f61757468322d6d6469726563746f722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/Antevenio/oauth2-mdirector?branch=master)[![Maintainability](https://camo.githubusercontent.com/eef90f1c4a9749921fe4b826e4e4b5910fe6f495834d9acf1fa4ec9949f2a26f/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f66313965373135656235323065376264366132392f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/Antevenio/oauth2-mdirector/maintainability)

OAuth client library specific to access MDirector API services, written in PHP.

This package provides MDirector () OAuth 2.0 support for the PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client).

As of now, only an OAuth2 implementation for the MDirector email marketing and transactional applications are provided. The package is composed of two [oauth2-client](https://github.com/thephpleague/oauth2-client)providers (for the email marketing and transactional services) and wrappers around them to hide the burden of the required OAuth2 negotiations.

As a consumer you may choose to use just a provider or a client wrapper, as it suits you best.

There is also a command line script to help you test it from the shell.

Requirements
------------

[](#requirements)

The following versions of PHP are supported.

- PHP 5.6
- PHP 7.0
- PHP 7.1
- PHP 7.2

Installation
------------

[](#installation)

```
composer require antevenio/oauth2-mdirector

```

Usage
-----

[](#usage)

As mentioned before, you can choose to use just a provider or the wrapper around it. Here you can find examples for each case:

### 1. MDirector Oauth2-client provider (email marketing application)

[](#1-mdirector-oauth2-client-provider-email-marketing-application)

You can find the [oauth2-client](https://github.com/thephpleague/oauth2-client) provider under [OAuth2/Client/Provider](https://github.com/Antevenio/mdirector-oauth-client-php/tree/master/src/OAuth2/Client/Provider), for generic usage instructions please refer to generic usage in the [oauth2-client github project](https://github.com/thephpleague/oauth2-client).

The MDirector email marketing provider as of now is just providing the **Resource Owner Password Credentials Grant**having a generic client\_id named **webapp**. Here is an example to get a valid accessToken:

```
$provider = new \MDOAuth\OAuth2\Client\Provider\MDirector();

try {
    // Try to get an access token using the resource owner password credentials grant.
    $accessToken = $provider->getAccessToken('password', [
        'username' => '{yourCompanyId}',
        'password' => '{yourApiSecret}'
    ]);
} catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) {
    // Failed to get the access token
    exit($e->getMessage());
}
```

When building your requests to the mdirector api, take into account that our api expects the parameters to be on the query string for *GET* requests, or being application/x-www-form-urlencoded on the body of the request for any other method

i.e. *POST*, *PUT*, *DELETE*... etc.

### 2. Transactional Oauth2-client provider (transactional application)

[](#2-transactional-oauth2-client-provider-transactional-application)

You can find the [oauth2-client](https://github.com/thephpleague/oauth2-client) provider under [OAuth2/Client/Provider](https://github.com/Antevenio/mdirector-oauth-client-php/tree/master/src/OAuth2/Client/Provider), for generic usage instructions please refer to generic usage in the [oauth2-client github project](https://github.com/thephpleague/oauth2-client).

The Transactional provider as of now is just providing the **Resource Owner Password Credentials Grant**having a generic client\_id named **webapp**. Here is an example to get a valid accessToken:

```
$provider = new \MDOAuth\OAuth2\Client\Provider\Transactional();

try {
    // Try to get an access token using the resource owner password credentials grant.
    $accessToken = $provider->getAccessToken('password', [
        'username' => '{yourCompanyId}',
        'password' => '{yourApiSecret}'
    ]);
} catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) {
    // Failed to get the access token
    exit($e->getMessage());
}
```

When building your requests to the transactional api, take into account that our api expects the parameters to be on the query string for *GET* requests, or being application/json encoded on the body of the request for any other method

i.e. *POST*, *PUT*, *DELETE*... etc.

The headers:

```
Content-Type: application/json

```

and

```
Accept: application/json

```

Are required on every request.

### 3. Wrapper clients

[](#3-wrapper-clients)

The wrapper clients offer a simplified way to call the API. They take care of obtaining tokens and refreshing them where needed. You just have to set parameters as an associative array, the wrapper knows how to pass them depending on the specified method. You can also specify a custom user-agent to be sent on request headers ("*oauth2-mdirector client*" by default)

Example of use:

```
$companyId = 'yourCompanyId';
$secret = 'yourApiSecret';

$client = (new \MDOAuth\OAuth2\Wrapper\MDirector\Factory())->create($companyId, $secret);
$response = $client->setUri('https://api.mdirector.com/api_contact')
    ->setMethod('get')
    ->setParameters([
        'email' => 'myemail@mydomain.org'
    ])
    ->setUserAgent('MyOwnUserAgent 1.0')
    ->request();

echo $response->getBody()->getContents();
```

### 3. Shell script

[](#3-shell-script)

The library also provides a [console](https://github.com/symfony/console) client so you can call the mdirector api from a shell. To do so run:

```
$ ./bin/mdirector-oauth-client oauth2:mdirector --help

```

The command will display some self explanatory help about its usage and parameters.

### 4. Others

[](#4-others)

If you plan on using another client implementation, or have to call the API using a language other than PHP, here you'll find the little bits of information you'll need to know:

You'll be asking for access tokens using "***webapp***" as your fixed client\_id, specifying **password** as the grant type, being your *company id* your **username** and your *secret* your **password**.

The endpoint for getting such tokens (or refresh them) would be:

And you'll be carrying your token on a Bearer header in your requests. ()

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance47

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~43 days

Recently: every ~98 days

Total

11

Last Release

2312d ago

Major Versions

0.0.10 → 1.0.02020-01-09

### Community

Maintainers

![](https://www.gravatar.com/avatar/255796cf8d7b620f5fb4ab1bb1b89395ef95076c5d1022bb1e05635119def4ff?d=identicon)[pinfake](/maintainers/pinfake)

---

Top Contributors

[![pinfake](https://avatars.githubusercontent.com/u/3945156?v=4)](https://github.com/pinfake "pinfake (15 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/antevenio-mdirector-oauth-client/health.svg)

```
[![Health](https://phpackages.com/badges/antevenio-mdirector-oauth-client/health.svg)](https://phpackages.com/packages/antevenio-mdirector-oauth-client)
```

###  Alternatives

[phan/phan

A static analyzer for PHP

5.6k11.2M1.1k](/packages/phan-phan)[illuminate/console

The Illuminate Console package.

12944.1M5.1k](/packages/illuminate-console)[php-soap/wsdl

Deals with WSDLs

173.5M12](/packages/php-soap-wsdl)[php-soap/wsdl-reader

A WSDL reader in PHP

212.3M9](/packages/php-soap-wsdl-reader)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
