1

I am working on a work module for integrating our law-firms management system with Zoho WorkDrive. I am using Java for the module. I have had to go through their WorkDrive APIs but it's inconsistent and hard to understand/ follow through. My main problem is how do I use the Zoho-oauthtoken I get when I generate the Access and refresh tokens? there is a section in their docs that says:

Once your app receives the access token, send the token in your HTTP authorization header to Zoho WorkDrive API with the value "Zoho-oauthtoken {access_token}" for each endpoint (for each request)

So when I tried what their docs say like this(My REST client is Insomnia by the way): enter image description here, I get a 401 Unauthorized. When i remove the Zoho-oauthtoken prefix, this is what happens: enter image description here. For context, here I was trying to create a new Team Folder in my trial team in my own Zoho Account, but the problem is the same with all the other endpoints I am trying to interact with.

The Java Part

In terms of Java code, here is how I am declaring the Scopes, I just copied their examples from their docs so I know I am somewhat on the right track:

protected static final String FILE_SCOPE = "WorkDrive.files.ALL,";
protected static final String TEAM_FOLDER_SCOPE = "WorkDrive.teamfolders.ALL";

Then I am using this to generate the Access and Refresh token:

/**
* SOME CODE OMITTED FOR CLARITY
*/
final String CLIENT_ID = this.CLIENT_ID;
final String CLIENT_SECRET = this.CLIENT_SECRET;
final String SCOPE = this.FILE_SCOPE + this.TEAM_FOLDER_SCOPE;
final String REDIRECT_URI = "https://localhost:8443/clientmanager/control/successZoho";

// Get the grant token from the Session context
String grantToken = (String) request.getSession().getAttribute("zohoGrantToken");

final String TOKEN_ENDPOINT = String.format(
"https://accounts.zoho.com/oauth/v2/token?code=%s&client_secret=%s&redirect_uri=%s&grant_type=authorization_code&client_id=%s&scope=%s",
grantToken, CLIENT_SECRET, REDIRECT_URI, CLIENT_ID, SCOPE
        );
/**
* SOME CODE OMITTED FOR CLARITY
*/

I need some help getting this to work because I am on a tight schedule. Have emailed the Zoho WorkDrive support team bu they have not responded yet.Any help or suggestion would be appreciated.

0 Answers0