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

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

asad/oauth2-zoho
================

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

1.1.0(5y ago)6299.8k↑30.8%6[2 PRs](https://github.com/asadku34/oauth2-zoho/pulls)1MITPHPCI failing

Since May 8Pushed 2y ago1 watchersCompare

[ Source](https://github.com/asadku34/oauth2-zoho)[ Packagist](https://packagist.org/packages/asad/oauth2-zoho)[ Docs](https://github.com/asad/oauth2-zoho)[ RSS](/packages/asad-oauth2-zoho/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (7)Versions (3)Used By (1)

ZOHO Provider for OAuth 2.0 Client
==================================

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

[![Latest Version on Packagist](https://camo.githubusercontent.com/95129b4e44a91155fba9055a9a55847dbbff67dd234da43875bfcab2fe9e5e5c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f617361642f6f61757468322d7a6f686f2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/asad/oauth2-zoho)[![Build Status](https://camo.githubusercontent.com/d577716c4d26c982e67f3d97e3f140d836e248b8f8e287f148596e83d3376a7b/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f617361646b7533342f6f61757468322d7a6f686f2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/asadku34/oauth2-zoho)[![Quality Score](https://camo.githubusercontent.com/80723a106ee5f429503ca9a95fa13a99bcf36c775ff0230024601fecedb585bf/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f617361646b7533342f6f61757468322d7a6f686f2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/asadku34/oauth2-zoho)[![Total Downloads](https://camo.githubusercontent.com/eee8583d34ffcc09ab5451c5459a8d0a215ff814772327af7315ed80d9c2bd06/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f617361642f6f61757468322d7a6f686f2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/asad/oauth2-zoho)[![License](https://camo.githubusercontent.com/850eae1099d2b05f53383473d7cd51f9bc1ab09b7d0d9e5122f1dd930efdcc6d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d6173686170652f6170697374617475732e737667)](https://packagist.org/packages/asad/zoho-cliq)

This package provides [ZOHO OAuth 2.0](https://www.zoho.com/crm/developer/docs/api/oauth-overview.html) support for the PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client).

To use this package, it will be necessary to have a ZOHO client ID and client secret. These are referred to as `{zoho-client-id}` and `{zoho-client-secret}`in the documentation.

Please follow the [ZOHO instructions](https://www.zoho.com/crm/developer/docs/api/oauth-overview.html) to create the required credentials.

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

[](#installation)

You can install the package via composer:

```
composer require asad/oauth2-zoho
```

Usage
-----

[](#usage)

### Authorization Code Flow

[](#authorization-code-flow)

```
use Asad\OAuth2\Client\Provider\Zoho;

$provider = new Zoho([
    'clientId' => '{zoho-client-id}',
    'clientSecret' => '{zoho-client-secret}',
    'redirectUri' => 'http://localhost:8000/zoho/oauth2',
    'dc' => 'AU' //It will be optional if your ZOHO are in US location
]);

if (!isset($_GET['code'])) {
    // If we don't have an authorization code then get one
    $authUrl = $provider->getAuthorizationUrl([
        'scope' => [
            'ZohoCRM.modules.ALL', //Important: Define your data accessability scope here
            'ZohoCRM.settings.ALL',
        ],
        'access_type' => 'offline', //Important: If you want to generate the refresh token, set this value as offline
        'prompt' => 'consent'       //Important: Will not return a refresh token if this is not also set
    ]);

    $_SESSION['oauth2state'] = $provider->getState();
    header('Location: ' . $authUrl);
    exit;

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

    unset($_SESSION['oauth2state']);
    exit('Invalid state');
} else {

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

        //$user = $provider->getResourceOwner($token);

        echo $access_token = $token->getToken();

        echo $refresh_token = $token->getRefreshToken(); //Save this refresh token to somewehre

        echo $token->getExpires();

    } catch (\Exception $e) {
        //handle you exception
    }
}
```

Refreshing a Token
------------------

[](#refreshing-a-token)

Refresh tokens are only provided to applications which request offline access. You can specify offline access by passing the access\_type option in your getAuthorizationUrl() request.

```
use Asad\OAuth2\Client\Provider\Zoho;
use League\OAuth2\Client\Grant\RefreshToken;

$provider = new Zoho([
    'clientId' => '{zoho-client-id}',
    'clientSecret' => '{zoho-client-secret}',
    'dc' => 'AU' //It will be optional if your ZOHO are in US location
]);

$refreshToken = 'FromYourStoredData';
$grant = new RefreshToken();
$token = $provider->getAccessToken($grant, ['refresh_token' => $refreshToken]);
```

### Testing

[](#testing)

```
composer test
```

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Asadur Rahman](https://github.com/asadku34)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity43

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

Total

2

Last Release

1946d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2770949?v=4)[Sk Asadur Rahman](/maintainers/asadku34)[@asadku34](https://github.com/asadku34)

---

Top Contributors

[![asadku34](https://avatars.githubusercontent.com/u/2770949?v=4)](https://github.com/asadku34 "asadku34 (2 commits)")[![tm1000](https://avatars.githubusercontent.com/u/564256?v=4)](https://github.com/tm1000 "tm1000 (2 commits)")[![phpfui](https://avatars.githubusercontent.com/u/7434059?v=4)](https://github.com/phpfui "phpfui (1 commits)")

---

Tags

clientoauthoauth2authorizationauthorisationZoho

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[stevenmaguire/oauth2-keycloak

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

2306.4M45](/packages/stevenmaguire-oauth2-keycloak)[patrickbussmann/oauth2-apple

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

1152.8M12](/packages/patrickbussmann-oauth2-apple)[omines/oauth2-gitlab

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

36779.2k16](/packages/omines-oauth2-gitlab)[league/oauth2-instagram

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

661.1M48](/packages/league-oauth2-instagram)[mollie/oauth2-mollie-php

Mollie Provider for OAuth 2.0 Client

261.8M1](/packages/mollie-oauth2-mollie-php)[dalpras/oauth2-gotowebinar

LogMeIn GoToWebinar OAuth 2.0 Client Provider for the PHP League's OAuth 2.0 Client

1246.3k](/packages/dalpras-oauth2-gotowebinar)

PHPackages © 2026

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