{"id":29251859,"url":"https://github.com/weble/zohoclient","last_synced_at":"2025-07-04T01:34:11.281Z","repository":{"id":35208042,"uuid":"209071544","full_name":"Weble/ZohoClient","owner":"Weble","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-27T15:40:50.000Z","size":183,"stargazers_count":11,"open_issues_count":2,"forks_count":8,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-06-22T02:51:33.318Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Weble.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"weble"}},"created_at":"2019-09-17T14:09:32.000Z","updated_at":"2025-02-27T15:40:50.000Z","dependencies_parsed_at":"2024-02-07T18:25:40.020Z","dependency_job_id":"31807636-ab64-44dc-96f8-ae105c006a5b","html_url":"https://github.com/Weble/ZohoClient","commit_stats":{"total_commits":73,"total_committers":7,"mean_commits":"10.428571428571429","dds":0.3835616438356164,"last_synced_commit":"179fa677cdad3a4cb0262fb6f8276827a93044e8"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/Weble/ZohoClient","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Weble%2FZohoClient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Weble%2FZohoClient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Weble%2FZohoClient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Weble%2FZohoClient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Weble","download_url":"https://codeload.github.com/Weble/ZohoClient/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Weble%2FZohoClient/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263431199,"owners_count":23465492,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-04T01:34:10.331Z","updated_at":"2025-07-04T01:34:11.262Z","avatar_url":"https://github.com/Weble.png","language":"PHP","funding_links":["https://github.com/sponsors/weble"],"categories":[],"sub_categories":[],"readme":"# Zoho API OAuth Client - PHP SDK\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/weble/zohoclient.svg?style=flat-square)](https://packagist.org/packages/weble/zohoclient)\n[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/weble/zohoclient/run-tests?label=tests\u0026style=flat-square)](https://github.com/weble/zohoclient/actions?query=workflow%3Arun-tests)\n[![Total Downloads](https://img.shields.io/packagist/dt/weble/zohoclient.svg?style=flat-square)](https://packagist.org/packages/weble/zohoclient)\n\nThis Library is a SDK in PHP that simplifies the usage of the Zoho Apis, providing a simple client to deal\nwith the OAuth2 implementation, as described here: [https://www.zoho.com/accounts/protocol/oauth.html](https://www.zoho.com/accounts/protocol/oauth.html)\n\nThe library aims to provide you with a streamlined way to generate the access_token you need to call \nany zoho api you need.\n\n## Installation\n\n```\ncomposer require weble/zohoclient \n```\n\n## Example Usages (Offline Mode)\n\n### Retrieve the url to authenticate against ZOHO and retrieve the access Token / Refresh Token for the first time\n```php\nrequire_once './vendor/autoload.php';\n\n$client = new \\Weble\\ZohoClient\\OAuthClient('{CLIENT_ID}', '{CLIENT_SECRET}', '{REGION}', '{REDIRECTURL}');\n$client-\u003eofflineMode(); // this needs to be set if you want to be able to refresh the token\n$client-\u003epromptForConsent(); // Optional setting: Prompts for user consent each time your app tries to access user credentials.\n\n// Get the url\n$client-\u003esetScopes([]); // Set the zoho scopes you need, see https://www.zoho.com/crm/developer/docs/api/v2/scopes.html\n$url = $client-\u003egetAuthorizationUrl();\n$state = $client-\u003egetState(); // Get the state for security, and save it (usually in session)\n\nredirect($url); // Do your redirection as you prefer\n\n// Wait for the user to redirect...\n\n// In the redirection page, check for the state you got before and that you should've stored\nif ($state !== $_GET['state']) {\n    throw new \\Exception('Someone is tampering with the oauth2 request');\n}\n\n// Try to get an access token (using the authorization code grant)\ntry {\n    $client-\u003esetGrantCode($_GET['code']);\n    \n    // if you set the offline mode, you can also get the refresh token here (and store it)\n    $refreshToken = $client-\u003egetRefreshToken();\n    \n    // get the access token (and store it probably)\n    $token = $client-\u003egetAccessToken();\n    \n} catch (\\Exception $e) {\n    // handle your exceptions\n}\n```\n\n## Example Usage (Online Mode)\n```php\nrequire_once './vendor/autoload.php';\n\n$client = new \\Weble\\ZohoClient\\OAuthClient('{CLIENT_ID}', '{CLIENT_SECRET}');\n$client-\u003esetRegion(\\Weble\\ZohoClient\\Enums\\Region::us());\n$client-\u003esetRedirectUri('{REDIRECT_URI_OF_YOUR_APP}');\n$client-\u003eonlineMode();\n\n// When you get redirected back to your REDIRECT_URI_OF_YOUR_APP\n$code = $_GET['code'];\n$client-\u003esetGrantCode($code);\n\n// Done!\n$accessToken = $client-\u003egetAccessToken();\n\n// Check if it's expired\n$isExpired = $client-\u003eaccessTokenExpired();\n\n```\n\n\n## Modes\nZoho OAuth v2 provides two main ways to obtain an access token:\n\n### 1) Online\nThis is the \"standard\" way used when you need to ask you zoho users to authenticate with their zoho account, and then\ncall the apis on their behalf (ie: as if they were logged in an where quering the apis). This is usually done to login as them\nand automate some kind of process through the apis, or when you just need a quick access to their profile, for example\nto login / get their name / get their profile.\n\nThe Online mode is the easiest to implement, but generates an access token that expires, usually after 1 hour, so it can't be stored\nor renewed without a refresh token, that you won't get with this method. After the token expire, you will need to ask\nyour users to login again.\n\n### 2) Offline\nThis one is preferred when you need to autonomously renew the access token yourself. Used in all the \"machine to machine\"\ncommunication, and it's the best way when you are using the apis to, for example, sync with a 3rd party application, \nlike your ERP or Ecommerce website.\n\nThe offline mode generates both an access token and a refresh token, than you **need** to store locally, and use it to refresh\nthe access token when it expires.\n\nThe library deals with the refresh process automatically, so you don't need to worry about that.\n    \n## Contributing\n\nFinding bugs, sending pull requests or improving the docs - any contribution is welcome and highly appreciated\n\n## Versioning\n\nSemantic Versioning Specification (SemVer) is used.\n\n## Copyright and License\n\nCopyright Weble Srl under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweble%2Fzohoclient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweble%2Fzohoclient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweble%2Fzohoclient/lists"}