Hi everyone!
Welcome back to another week of Kaizen!
In this post, we will shed some light on the OAuth2.0 protocol and how you can use Zoho's Self Client option to authenticate your application and generate the tokens.
What is OAuth2.0?
OAuth 2.0 is an industry standard protocol specification that enables third-party applications (clients) to gain delegated access to protected resources in Zoho via an API.
Why should we use OAuth2.0?
- Clients are not required to support password authentication or store user credentials.
- Clients gain delegated access, i.e., access only to resources authenticated by the user.
- Users can revoke client's delegated access anytime.
- OAuth access tokens expire after a set time. If the client faces a security breach, user data will be compromised only until the access token is valid.
To use the Zoho CRM APIs, you must authenticate the application to make API calls on your behalf with an access token.
The access token, in return, must be obtained from a grant token (authorization code).
Zoho CRM APIs use the authorization code grant type to provide access to protected resources.
In this type,
- The web application redirects the user to the OAuth server.
The user sees the authorization prompt and approves the app's request as shown in the below image.
The user is redirected back to the application with an authorization code in the query string.
- The application exchanges the authorization code for an access token.
As you can see, this involves user intervention while authorizing your application.
When should you use Self Client?
If your application is a stand-alone application that performs only back-end jobs like data-sync(without any manual intervention), you cannot use this authorization code flow.
In the below example image, the data sync happens between Zoho CRM and your legacy Product Management system. So, it is perfect to use the Self Client option as it does not need an UI for this type of application. Using this flow, you can generate the grant token, access, and refresh tokens.
How to use Self Client?
2. Choose Self Client from the list of client types.
3. Click Create on the Create New Client page and click OK in the pop up to enable a self client for your account.
4. Now, your client ID and secret is displayed under the Client Secret tab.
5. Click the Generate Code tab to generate the Grant token.