Copy to clipboard
//We assume that the API call to initialize the app comes to this method.
//We also assume that you set the path of the configuration property file in the system property.
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//When you call - ZohoOAuthClient.getInstance().getLoginWithZohoUrl(); the SDK starts to get initialized.
//Then, a valid Zoho account URL is returned, based on your configuration property data.
response.sendRedirect(ZohoOAuthClient.getInstance().getLoginWithZohoUrl())
}
//After the app permissions are accepted, Zoho calls the redirectURI specified in the property file.
//We assume that the redirect API call comes to this method.
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String code = request.getParameter("code"); //getting grant_token from request
ZohoOAuthClient client = ZohoOAuthClient.getInstance();
try {
//If no error occurs while generating the access token, oauth token data is generated and stored in the persistence class specified.
client.generateAccessToken(code);
} catch (ZohoOAuthException e) {
e.printStackTrace();
}
}