This took an unnecessarily long time to figure out, and neither the Zoho documentation, help, nor code samples were useful. I found some off-hand references to Postman (the app) in a mention elsewhere, and it finally dawned on me:
Zoho automates part of the credential setup via their website, then they expect you to figure out the next several steps without explaining it or providing a simple onboarding per-method. It appears from many comments that support does not understand that their documentation is indeed opaque in this regard.
This general method for self client
will likely be a reasonable explainer for the other Zoho sdks as well.
This is incredibly convoluted and requires the use of a third party app such as Postman (or forming an HTTP POST request another way, within the time allotted).
To use the Zoho API, you must have an access_token
. To obtain an access_token
, you must utilize the grant code
, which is generated after creating the client id and client secret in the api console page.
@see https://www.zoho.com/crm/developer/docs/api/v6/auth-request.html
- Create
clientID
andclientSecret
on the developer api console https://api-console.zoho.com Generate code
on the next tab, withZohoCRM.modules.ALL
and 10 minutes. Choose production, copy thegrant token
.- NOW you have to manually create a
POST
. Download the Postman app and setup the following:- type
POST
- url https://accounts.zoho.com/oauth/v2/token (pay attention to the docs, your base url may change based on your location)
- params:
grant_type=authorization_code client_id=<from api console> client_secret=<from api console> redirect_uri=nothing code=<grant code from api console>
- type
- Success from the POST result in postman should contain the
access_token
andrefresh_token
.
NOW you can provide these to the OAuthBuilder
in the sdk such as:
$token = (new OAuthBuilder())
->clientId($_ENV['ZOHO_CLIENT_ID'])
->clientSecret($_ENV['ZOHO_CLIENT_SECRET'])
->accessToken($_ENV['ZOHO_ACCESS_TOKEN'])
->refreshToken($_ENV['ZOHO_REFRESH_TOKEN'])
->build();