Let us quickly walk through the sequence of steps to use Java SDK.
2. Create the File hierarchy in your eclipse project as shown below:
3.
Create a folder named "resources" under "{yourproject}/Java
Resources/src", as shown in the file hierarchy and place the following
properties files into
it.oauth_configuration.properties
zcrm_configuration.properties
Create oauthtoken.properties file
as shown in the file hierarchy to store all the token values.This is
created under a folder named "path_to_tokens". When the authentication
process is complete, the tokens are generated and placed in the
properties file automatically as shown here.
4.
Implement Oauth persistence through ZohoOAuthFilePersistence by
providing the relative path of the oauth_tokens.properties file,
discussed in the previous step with oauth_configuration.properties.
5.
Get the access token and refresh token by executing
the InitOauth.java created under the
package com.zoho.crmsdk.oauth_configuration. Use the following java code
in your InitOauth.java.
(Please paste the grant token value that is obtained during the authentication process, in the string literal mentioned.)
Refer here to generate the grant token.
- package com.zoho.crmsdk.oauth_configuration;
- import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
- import com.zoho.oauth.client.ZohoOAuthClient;
- import com.zoho.oauth.contract.ZohoOAuthTokens;
- public class InitOauth {
- public static void main(String[] args) throws Exception {
- generateToken();
- }
- public static void generateToken() throws Exception {
- ZCRMRestClient.initialize();
- ZohoOAuthClient cli = ZohoOAuthClient.getInstance();
- String grantToken = "1000.d995c249da11cb5fa3b3c2fc40bd6ba2.e0fb62255485e425fca800e7030d60e7";
- ZohoOAuthTokens tokens = cli.generateAccessToken(grantToken);
-
System.out.println(">>>> grantToken" + grantToken + "
>>>> accessToken : " + tokens.getAccessToken()+"
>>>>> ref token :"+tokens.getRefreshToken());
- }
- }
Now
it is the high time to create your java resource file that contains the
application logic. The following simple java program:
- Sets the mobile number of a particular lead in your Zoho CRM's Leads record.
- Retrieves the mobile number from the lead record and generates API response in the console.