PHPackages                             elegantmedia/oauth2-myob - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. elegantmedia/oauth2-myob

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

elegantmedia/oauth2-myob
========================

MYOB oAuth Client (based on League's conventions)

v0.1.0(5y ago)0870—0%MITPHPPHP ^7.2|^8.0

Since Apr 21Pushed 5y ago2 watchersCompare

[ Source](https://github.com/elegantmedia/oAuth2-MYOB)[ Packagist](https://packagist.org/packages/elegantmedia/oauth2-myob)[ Docs](https://github.com/elegantmedia/oauth2-myob)[ RSS](/packages/elegantmedia-oauth2-myob/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

Myob Provider for OAuth 2.0 Client
==================================

[](#myob-provider-for-oauth-20-client)

[![Latest Version on Packagist](https://camo.githubusercontent.com/aa3933773cc122c8ace53dee08d13f6ea86de81bcce67c5aaa535c3243115ca3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f656c6567616e746d656469612f6f61757468322d6d796f622e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/elegantmedia/oauth2-myob)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

This package allows you to use [Myob oAuth API](https://developer.myob.com/api/accountright/).

Before using it, you'll need an API key from [developer website](https://my.myob.com.au/).

Other reference links

WebsiteURLDeveloper SiteAPI ReferencePostman CollectionInstall
-------

[](#install)

Via Composer

```
$ composer require elegantmedia/oauth2-myob
```

Usage
-----

[](#usage)

### Authorization

[](#authorization)

The example below shows how to get an authorization URL from the Provider. For a complete example see [examples/auth.php](examples/auth.php).

```
require __DIR__ . '/vendor/autoload.php';

$provider = new \ElegantMedia\OAuth2\Client\Provider\Myob([
	'clientId' => 'your_client_id',
	'clientSecret' => 'your_secret',
	'redirectUri' => 'https://example.com/your-url',
]);

// get initial authorization URL
$authUrl = $provider->getAuthorizationUrl();

// save the state value in session to prevent CSRF attacks
$_SESSION['oauth2state'] = $provider->getState();

header('Location: ' . $authUrl);
exit;
```

### Get Token

[](#get-token)

The example below shows how to get an access token from the Provider. For a complete example see [examples/post.php](examples/post.php).

```
// valid state, so we try to get an access token
$accessToken = $provider->getAccessToken('authorization_code', [
	'code' => $params['code'],
]);

// You'll have to store these for later use
echo 'Access Token: ' . $accessToken->getToken() . "\r\n\r\n";
echo 'Refresh Token: ' . $accessToken->getRefreshToken() . "\r\n\r\n";
echo 'Expires in: ' . $accessToken->getExpires() . "\r\n\r\n";
echo 'Already expired? ' . ($accessToken->hasExpired() ? 'expired' : 'not expired') . "\r\n\r\n";

$user = $provider->getResourceOwner($accessToken);

// Get resource User
// https://apisupport.myob.com/hc/en-us/articles/360003860376-Validating-the-User
echo 'User ID : ' . $user->getId() . "\r\n";
echo 'Username : ' . $user->getUsername() . "\r\n";
```

### Refresh Token

[](#refresh-token)

The example below shows how to get an a new token for an expired code. For a complete example see [examples/post.php](examples/refresh.php).

```
$refreshToken = 'old-token';
$expires = 'old-timestamp';

$expiresAt = \DateTime::createFromFormat('U', $expires);

if ($expiresAt->getTimestamp() > time()) {
	echo "Not expired \r\n";
} else {
	echo "Expired \r\n";

	$accessToken = $provider->getAccessToken('refresh_token', [
		'refresh_token' => $refreshToken,
	]);

	// We have an access token, which we may use in authenticated
	// requests against the service provider's API.

	echo 'Access Token: ' . $accessToken->getToken() . "\r\n";
	echo 'Refresh Token: ' . $accessToken->getRefreshToken() . "\r\n";
	echo 'Expires in: ' . $accessToken->getExpires() . "\r\n";
	echo 'Already expired? ' . ($accessToken->hasExpired() ? 'expired' : 'not expired') . "\r\n";

}

$user = $provider->getResourceOwner($accessToken);
echo 'User ID : ' . $user->getId() . "\r\n";
echo 'Username : ' . $user->getUsername() . "\r\n";
```

Contributing
------------

[](#contributing)

If you see any bugs, please send a pull-request.

Credits
-------

[](#credits)

- [Elegant Media](https://github.com/elegantmedia)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

1847d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/da3702531f01e83fd1f444563b6df50e14033582eec6b5322e440ec206195160?d=identicon)[emediadevops](/maintainers/emediadevops)

---

Tags

oauthoauth2elegantmediamyoboauth2-myobmyobaccountrightmyobessentialsaccountrightv2myobauthauthmyob

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/elegantmedia-oauth2-myob/health.svg)

```
[![Health](https://phpackages.com/badges/elegantmedia-oauth2-myob/health.svg)](https://phpackages.com/packages/elegantmedia-oauth2-myob)
```

###  Alternatives

[league/oauth2-google

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

41721.2M118](/packages/league-oauth2-google)[knpuniversity/oauth2-client-bundle

Integration with league/oauth2-client to provide services

83416.7M61](/packages/knpuniversity-oauth2-client-bundle)[thenetworg/oauth2-azure

Azure Active Directory OAuth 2.0 Client Provider for The PHP League OAuth2-Client

2509.6M48](/packages/thenetworg-oauth2-azure)[stevenmaguire/oauth2-keycloak

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

2275.9M27](/packages/stevenmaguire-oauth2-keycloak)[league/oauth2-facebook

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

32013.0M66](/packages/league-oauth2-facebook)[patrickbussmann/oauth2-apple

Sign in with Apple OAuth 2.0 Client Provider for The PHP League OAuth2-Client

1132.5M6](/packages/patrickbussmann-oauth2-apple)

PHPackages © 2026

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