PHPackages                             ekoapp/eko-oauth-sdk - 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. ekoapp/eko-oauth-sdk

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

ekoapp/eko-oauth-sdk
====================

1.1(6y ago)21671[2 PRs](https://github.com/EkoCommunications/EkoOAuthSDK-PHP/pulls)PHP

Since Dec 21Pushed 5y ago27 watchersCompare

[ Source](https://github.com/EkoCommunications/EkoOAuthSDK-PHP)[ Packagist](https://packagist.org/packages/ekoapp/eko-oauth-sdk)[ Docs](https://github.com/EkoCommunications/EkoOAuthSDK-PHP)[ RSS](/packages/ekoapp-eko-oauth-sdk/feed)WikiDiscussions master Synced today

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

EkoOAuthSDK-PHP
===============

[](#ekooauthsdk-php)

An OAuth authentication client for integrating 3rd party application with Eko App.

### Prerequisites

[](#prerequisites)

Client application must be registered with Eko first. These values, `redirect_uri`, `client_id`, `client_secret` and `eko_uri`, will be defined during registration process.

### Running Example

[](#running-example)

1. Edit the `client_id`, `client_secret`, `redirect_uri` and `eko_uri` in `/examples/app.php`.
2. Go to `http://localhost/path/to/project/examples/app.php` via the browser

### Installation

[](#installation)

```
composer require ekoapp/eko-oauth-sdk
```

### Usage

[](#usage)

See `examples/app.php` for the complete flow of usage.

#### 1. Initialization

[](#1-initialization)

```
use EkoApp\OAuth\EkoOAuthClient;

$client = new EkoOAuthClient();
$client->setClientId(CLIENT_ID);
$client->setClientSecret(CLIENT_SECRET);
$client->setRedirectUri(REDIRECT_URI);
$client->setEkoUri(EKO_URI);
```

#### 2. Authentication

[](#2-authentication)

To authenticate a user, the client application must redirect the user to the url below.

- Create a redirect url to Eko authentication endpoint

```
$_SESSION['state'] = $client->createState();
// DO NOT forget to store this state into the session to validate it when Eko redirect back to your endpoint

$authEndpointUrl = $client->createAuthenticateUrl($_SESSION['state']);
```

#### 3. Get token and user info

[](#3-get-token-and-user-info)

The client application must setup an endpoint which must match the predefined `redirect_uri`. After authentication success or fail, Eko will redirect the user back to this `redirect_uri` endpoint along with `state` and `code` (authentication code) as query parameters. The client application must validate the incoming state with the one previously store on the session. Then, the client application use the `code` to retrieve access token and use the access token to retrieve user info. DO NOT use the `code` if state validation fail.

- Validate state (if fail, exceptions will be thrown)

```
$client->validateState($_SESSION['state'], $state);
```

- Get token

```
$token = $client->requestToken($code);
```

```
// Retreiving values from access token
$accessToken = $token->getAccessToken();
$refreshToken = $token->getRefreshToken();
$tokenType = $token->getTokenType();
$expiresIn = $token->getExpiresIn();
$scopes = $token->getScopes();
$rawIdToken = $token->getRawIdToken();
$idToken = $token->getIdToken();
```

- Get ID token

```
$idToken = $token->getIdToken();
```

```
// Retreiving values from id token
$firstName = $idToken->firstname;
$lastName = $idToken->lastname;
$email = $idToken->email;
```

- Get user info

```
$userInfo = $client->requestUserInfo($token->getAccessToken());
```

```
// Retreiving values from user info
$userId = $userInfo->_id;
$firstName = $userInfo->firstname;
$lastName = $userInfo->lastname;
$email = $userInfo->email;
$networkId = $userInfo->networkId;
```

or a shortcut to retreive user info ...

- Get user info by `code`

```
$userInfo = $client->requestUserInfoByCode($code);
```

#### 4. Refresh Token

[](#4-refresh-token)

```
$token = $client->requestTokenByRefreshToken($token->getRefreshToken());
```

Release
-------

[](#release)

VersionChanges1.0.0- Initial release

Authors
-------

[](#authors)

- **Jura Boonnom** - *Initial work* - [jura-b](https://github.com/jura-b)

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity65

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 ~652 days

Total

2

Last Release

2461d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/29221127?v=4)[jura-b](/maintainers/jura-b)[@jura-b](https://github.com/jura-b)

---

Top Contributors

[![makhmudgaly](https://avatars.githubusercontent.com/u/19774176?v=4)](https://github.com/makhmudgaly "makhmudgaly (1 commits)")

---

Tags

eko oautheko openidekoapp

### Embed Badge

![Health badge](/badges/ekoapp-eko-oauth-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/ekoapp-eko-oauth-sdk/health.svg)](https://phpackages.com/packages/ekoapp-eko-oauth-sdk)
```

###  Alternatives

[google/auth

Google Auth Library for PHP

1.4k286.7M205](/packages/google-auth)[stevenmaguire/oauth2-keycloak

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

2276.2M36](/packages/stevenmaguire-oauth2-keycloak)[robsontenorio/laravel-keycloak-guard

🔑 Simple Keycloak Guard for Laravel

5181.1M3](/packages/robsontenorio-laravel-keycloak-guard)[ellaisys/aws-cognito

AWS Cognito package that allows Auth and other related features using the AWS SDK for PHP

121242.9k1](/packages/ellaisys-aws-cognito)[microsoft/kiota-authentication-phpleague

Authentication provider for Kiota using the PHP League OAuth 2.0 client to authenticate against the Microsoft Identity platform

153.8M9](/packages/microsoft-kiota-authentication-phpleague)[rainlab/user-plugin

User plugin for October CMS

11854.7k15](/packages/rainlab-user-plugin)

PHPackages © 2026

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