PHPackages                             yehudah/oauth2-zoho - 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. yehudah/oauth2-zoho

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

yehudah/oauth2-zoho
===================

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

36.8k↓50%3[1 PRs](https://github.com/yehudah/oauth2-zoho/pulls)PHP

Since Mar 13Pushed 6y ago1 watchersCompare

[ Source](https://github.com/yehudah/oauth2-zoho)[ Packagist](https://packagist.org/packages/yehudah/oauth2-zoho)[ RSS](/packages/yehudah-oauth2-zoho/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Zoho Provider for OAuth 2.0 Client
==================================

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

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

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

[](#requirements)

The following versions of PHP are supported.

- PHP 7.0

Usage
-----

[](#usage)

### Authorization Code Flow

[](#authorization-code-flow)

```
require_once 'vendor/autoload.php';

$provider = Postsmtp\OAuth2\Client\Provider\Zoho([
    'clientId'                => $client_id,    // The client ID assigned to you by the provider
    'clientSecret'            => $client_secret,   // The client password assigned to you by the provider
    'redirectUri'             => 'http://domain.com',
]);

// If we don't have an authorization code then get one
if (!isset($_GET['code'])) {

    $authorizationUrl = $provider->getAuthorizationUrl(
        [
            'scope' => 'ZohoMail.accounts.READ,ZohoMail.messages.READ',
            //Must use for refresh token
            'access_type' => 'offline'
        ]
    );

    // Get the state generated for you and store it to the session.
    $_SESSION['oauth2state'] = $provider->getState();

    // Redirect the user to the authorization URL.
    header('Location: ' . $authorizationUrl);
    exit;

// Check given state against previously stored one to mitigate CSRF attack
} elseif (empty($_GET['state']) || (isset($_SESSION['oauth2state']) && $_GET['state'] !== $_SESSION['oauth2state'])) {

    if (isset($_SESSION['oauth2state'])) {
        unset($_SESSION['oauth2state']);
    }

    exit('Invalid state');

} else {

    try {

        // Try to get an access token using the authorization code grant.
        $accessToken = $provider->getAccessToken('authorization_code', [
            'code' => $_GET['code']
        ]);

        // We have an access token, which we may use in authenticated
        // requests against the service provider's API.
        echo 'Access Token: ' . $accessToken->getToken() . "";
        echo 'Refresh Token: ' . $accessToken->getRefreshToken() . "";
        echo 'Expired in: ' . $accessToken->getExpires() . "";
        echo 'Already expired? ' . ($accessToken->hasExpired() ? 'expired' : 'not expired') . "";
        echo 'More values: ' . print_r( $accessToken->getValues(), true ) . "";

        // Using the access token, we may look up details about the
        // resource owner.
        $resourceOwner = $provider->getResourceOwner($accessToken);

        var_export($resourceOwner->toArray());

    } catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) {

        // Failed to get the access token or user details.
        exit($e->getMessage());

    }

}
```

### Refreshing a Token

[](#refreshing-a-token)

For refresh token pass `access_type=offline`.

Credits
-------

[](#credits)

- [Yehuda Hassine](https://postmansmtp.com)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/yehudah/oauth2-zoho/blob/master/LICENSE) for more information.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/172880?v=4)[yehuda](/maintainers/yehuda)[@yehuda](https://github.com/yehuda)

---

Top Contributors

[![yehudah](https://avatars.githubusercontent.com/u/1655373?v=4)](https://github.com/yehudah "yehudah (2 commits)")

---

Tags

oauth2oauth2-authenticationoauth2-clientoauth2-providerzoho

### Embed Badge

![Health badge](/badges/yehudah-oauth2-zoho/health.svg)

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

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

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

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

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