Initialization - Python SDK
Now the app is ready to be initialized after defining configuration file/dictionary for your app.
Generating grant and refresh tokens
For a Single User(self-authorized)
For self client apps, the self authorized grant token should be generated from the Zoho Developer Console (
https://accounts.zoho.com/developerconsole). The developer console has an option to generate grant token for a user directly. This option may be handy when your app is going to use only one CRM user's credentials for all its operations or for your development testing.
- Login to the User's account.
- Visit https://accounts.zoho.com/developerconsole
- Click on the Options → Self Client of the client for which you wish to authorize.
- Enter one or more (comma separated) valid Zoho CRM scopes that you wish to authorize in the “Scope” field and choose the time of expiry. Provide “aaaserver.profile.READ” scope along with Zoho CRM scopes.
- Copy the grant token that is displayed on the screen.
Generate refresh_token from grant token by making a POST request with the URL below:
https://accounts.zoho.com/oauth/v2/token?code={grant_token}&redirect_uri={redirect_uri}&client_id={client_id}&client_secret={client_secret}&grant_type=authorization_code
- Copy the refresh token for backup.
Note
- The generated grant token is valid only for the stipulated time you chose while generating it. Hence, the access and refresh tokens should be generated within that time.
- The OAuth client registration and grant token generation must be done in the same Zoho account's (meaning - login) developer console.
For Multiple Users
For multiple users, it is the responsibility of your client app to generate the grant token from the users trying to login.
- Your Application's UI must have a "Login with Zoho" option to open the grant token URL of Zoho, which would prompt for the user's Zoho login credentials.
- Upon successful login of the user, the grant token will be sent as a param to your registered redirect URL.
Generating access tokens
Access token can be generated by grant token or refresh token. Following any one of the two methods given below is sufficient.
The following code snippet should be executed from your main class to get access token.
- ZCRMRestClient.initialize()
- oauth_client = ZohoOAuth.get_client_instance()
- grant_token="paste_grant_token_here"
- oauth_tokens = oauth_client.generate_access_token(grant_token)
Please paste the generated grant token in the string literal mentioned. This is one time process only.
Generating access tokens from refresh token
The following code snippet should be executed from your main class to get access token.
- ZCRMRestClient.initialize()
- oauth_client = ZohoOAuth.get_client_instance()
- refresh_token="paste_refresh_token_here"
- user_identifier="provide_user_identifier_like_email_here"
- oauth_tokens = oauth_client.generate_access_token_from_refresh_token(refresh_token,user_identifier)
Please paste the generated refresh token in the string literal mentioned. This is one time process only.
Note
- The above code snippet is valid only once per grant token. Upon its successful execution, the generated access and refresh tokens would have been persisted through your persistence handler class.
- Once the OAuth tokens have been persisted, subsequent API calls would use the persisted access and refresh tokens. The SDK will take care of refreshing the access token using refresh token, as and when required.
Related Articles
Configuration - Python SDK
Before you get started with creating your python application, you need to first authenticate the app with Zoho. And to do that there are some configuration procedures that need to be in place. There are two methods in which you can authenticate your ...
Python SDK - An Overview
Python SDK offers a way to create client python applications that can be integrated with Zoho CRM. This SDK makes the access and use of necessary CRM APIs with ease. In other words, it serves as a wrapper for the REST APIs, making it easier to use ...
Responses & Exceptions - Python SDK
APIResponse, BulkAPIResponse and FileAPIResponse are the wrapper objects for Zoho CRM APIs’ responses. All API calling methods would return one of these three objects. A method-seeking entity would return APIResponse object, whereas a method-seeking ...
Initialization - C# SDK
Now the app is ready to be initialized after defining configuration file/dictionary for your app. Generating Grant tokens For a Single User(self-authorized) For self client apps, the self authorized grant token should be generated from the Zoho ...
Initialization - Node JS SDK
Whenever the app is started, the below code snippet is to be called for initialization. var ZCRMRestClient = require('zcrmsdk'); ZCRMRestClient.initialize().then(function() { //do whatever required after initialize }) Generating self-authorized grant ...