zoho oauth grant service added
This commit is contained in:
parent
f623ea33ff
commit
703995f959
2 changed files with 144 additions and 0 deletions
36
doc/zoho/README.md
Normal file
36
doc/zoho/README.md
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
# Zoho Web API
|
||||||
|
|
||||||
|
AGL Dubai nutzt Zoho als Platform zusammen mit einer lokalen Steuerkanzlei
|
||||||
|
|
||||||
|
## Test/Prod Account Imixs
|
||||||
|
|
||||||
|
https://api-console.zoho.eu/
|
||||||
|
https://api-console.zoho.eu/client/1000.NLTM2KUEHI696MSLGEIANATVGGX7IN
|
||||||
|
|
||||||
|
```
|
||||||
|
client ID= 1000.NLTM2KUEHI696MSLGEIANATVGGX7IN
|
||||||
|
client secret= ee9ba49f16e77c64abb89cea13542d2326d8d03ce8
|
||||||
|
```
|
||||||
|
|
||||||
|
# Testumgebung
|
||||||
|
|
||||||
|
https://books.zoho.eu/app/20105697367
|
||||||
|
https://accounts.zoho.eu/home#
|
||||||
|
|
||||||
|
API Docu:
|
||||||
|
|
||||||
|
https://www.zoho.com/books/api/v3/introduction/
|
||||||
|
|
||||||
|
Authentication:
|
||||||
|
|
||||||
|
https://www.zoho.com/books/api/v3/oauth/
|
||||||
|
|
||||||
|
Base API URI= https://accounts.zoho.eu/
|
||||||
|
|
||||||
|
## 1. Generating Grant Token
|
||||||
|
|
||||||
|
https://accounts.zoho.com/oauth/v2/auth?scope=ZohoBooks.invoices.CREATE,ZohoBooks.invoices.READ,ZohoBooks.invoices.UPDATE,ZohoBooks.invoices.DELETE&client_id=1000.NLTM2KUEHI696MSLGEIANATVGGX7IN&state=testing&response_type=code&redirect_uri=https://alexander-logistics-dwc.office-workflow.de/
|
||||||
|
|
||||||
|
## 2. Generate Access and Refresh Token
|
||||||
|
|
||||||
|
https://accounts.zoho.com/oauth/v2/token?code=1000.dd7exxxxxxxxxxxxxxxxxxxxxxxx9bb8.b6c0xxxxxxxxxxxxxxxxxxxxxxxxdca4&client_id=1000.NLTM2KUEHI696MSLGEIANATVGGX7IN&client_secret=ee9ba49f16e77c64abb89cea13542d2326d8d03ce8&redirect_uri=http://www.zoho.com/books&grant_type=authorization_code
|
||||||
|
|
@ -0,0 +1,108 @@
|
||||||
|
/*
|
||||||
|
* Imixs-Workflow
|
||||||
|
*
|
||||||
|
* Copyright (C) 2001-2020 Imixs Software Solutions GmbH,
|
||||||
|
* http://www.imixs.com
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You can receive a copy of the GNU General Public
|
||||||
|
* License at http://www.gnu.org/licenses/gpl.html
|
||||||
|
*
|
||||||
|
* Project:
|
||||||
|
* https://www.imixs.org
|
||||||
|
* https://github.com/imixs/imixs-workflow
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Imixs Software Solutions GmbH - Project Management
|
||||||
|
* Ralph Soika - Software Developer
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.alexanderlogistics.zoho;
|
||||||
|
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.imixs.workflow.exceptions.QueryException;
|
||||||
|
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.ejb.SessionContext;
|
||||||
|
import jakarta.ejb.Stateless;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import jakarta.ws.rs.GET;
|
||||||
|
import jakarta.ws.rs.Path;
|
||||||
|
import jakarta.ws.rs.Produces;
|
||||||
|
import jakarta.ws.rs.core.Context;
|
||||||
|
import jakarta.ws.rs.core.MediaType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dieser API Endpoint dient dazu über zoho einen sogenannten Grant Token zu
|
||||||
|
* erhalten.
|
||||||
|
*
|
||||||
|
* https://www.zoho.com/books/api/v3/oauth/
|
||||||
|
*
|
||||||
|
* Er dient als redirect URL wenn jemand einen solchen Token über den Browser
|
||||||
|
* anfordert.
|
||||||
|
* Der URL muss hier als CallBack URL angegeben sein!
|
||||||
|
*
|
||||||
|
* Beispiel:
|
||||||
|
*
|
||||||
|
* https://accounts.zoho.com/oauth/v2/auth?scope=ZohoBooks.invoices.CREATE,ZohoBooks.invoices.READ,ZohoBooks.invoices.UPDATE,ZohoBooks.invoices.DELETE&client_id=1000.NLTM2KUEHI696MSLGEIANATVGGX7IN&state=testing&response_type=code&redirect_uri=https://alexander-logistics-dwc.office-workflow.de/api/zoho/grant
|
||||||
|
*
|
||||||
|
* @version 1.0
|
||||||
|
* @author rsoika
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Path("/zoho")
|
||||||
|
@Stateless
|
||||||
|
public class ZohoOAuthGrantService {
|
||||||
|
|
||||||
|
@Context
|
||||||
|
private HttpServletRequest servletRequest;
|
||||||
|
|
||||||
|
@Context
|
||||||
|
HttpServletResponse servletResponse;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SessionContext ctx;
|
||||||
|
|
||||||
|
private static Logger logger = Logger.getLogger(ZohoOAuthGrantService.class.getName());
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/ping")
|
||||||
|
public String ping() {
|
||||||
|
logger.info("GET ping");
|
||||||
|
return "ping: " + System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method
|
||||||
|
*
|
||||||
|
* @param workflowgroup
|
||||||
|
* @param task
|
||||||
|
* @return
|
||||||
|
* @throws QueryException
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Path("/grant")
|
||||||
|
@Produces({ MediaType.TEXT_HTML })
|
||||||
|
public String getGrantToken()
|
||||||
|
throws QueryException {
|
||||||
|
|
||||||
|
logger.info("├── Receive Grant Token from Zoho");
|
||||||
|
String baseURI = servletRequest.getRequestURL().toString();
|
||||||
|
|
||||||
|
logger.info("│ ├── Base URI=" + baseURI);
|
||||||
|
|
||||||
|
return "Zoho Grant Token received!";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue