How to Authenticate with Zoho Desk API Using OAuth for a Next.js App
🔐 How to Authenticate with Zoho Desk API Using OAuth for a Next.js App
By Jazzed Technology
Integrating Zoho Desk into your Next.js application can unlock powerful support features — from ticket automation to real-time contact management. But like many OAuth-based APIs, the initial setup can be a bit tricky, especially when it comes to getting the scopes right.
In this post, we’ll walk you through how to generate and configure the following values for your .env
file:
ZOHO_CLIENT_ID=
ZOHO_CLIENT_SECRET=
ZOHO_REFRESH_TOKEN=
ZOHO_API_BASE_URL=https://desk.zoho.com
ZOHO_ORG_ID=
ZOHO_DEPARTMENT_ID=
ZOHO_DEFAULT_CONTACT_ID=
ZOHO_DEFAULT_PRODUCT_ID=
ZOHO_ACCOUNTS_URL=https://accounts.zoho.com
ZOHO_REDIRECT_URI=https://jazzgrewal.com
ZOHO_SCOPES=Desk.tickets.ALL,Desk.contacts.ALL,Desk.settings.READ,Desk.basic.READ,aaaserver.profile.READ
🧱 Step 1: Create a Zoho Self Client
- Go to the Zoho API Console.
- Click Add Client → Select Self Client.
- Fill in the following:
- Client Name: (e.g., JazzGrewal Desk Integration)
- Client Domain:
https://jazzgrewal.com
- Redirect URI:
https://jazzgrewal.com
- Click Create.
- You’ll receive your
ZOHO_CLIENT_ID
andZOHO_CLIENT_SECRET
.
🧾 Step 2: Generate a Grant Token
-
Within your Self Client, click Generate Code.
-
Use the following scopes (these are accurate for Zoho Desk):
Desk.tickets.ALL,Desk.contacts.ALL,Desk.settings.READ,Desk.basic.READ,aaaserver.profile.READ
❗ Common Mistake: Avoid using outdated scopes like
ZohoDesk.tickets.ALL
— these will throw an “invalid scopes” error. -
Once generated, copy the one-time-use grant token.
🔄 Step 3: Exchange Grant Token for Refresh Token
Send this POST request using curl, Postman, or in code:
POST https://accounts.zoho.com/oauth/v2/token
Content-Type: application/x-www-form-urlencoded
client_id=YOUR_CLIENT_ID
&client_secret=YOUR_CLIENT_SECRET
&grant_type=authorization_code
&code=YOUR_GRANT_TOKEN
&redirect_uri=https://jazzgrewal.com
✅ If successful, you’ll receive:
{
"access_token": "1000.xxxxx",
"refresh_token": "1000.xxxxx",
"expires_in": 3600,
"token_type": "Bearer"
}
Store the refresh_token
securely — this allows your Next.js backend to generate new access tokens programmatically.
🔎 Step 4: Fill in Remaining Values
Use your access token to fetch these:
Organization ID
GET https://desk.zoho.com/api/v1/organizations
Authorization: Zoho-oauthtoken ACCESS_TOKEN
Department ID
GET https://desk.zoho.com/api/v1/departments
Authorization: Zoho-oauthtoken ACCESS_TOKEN
Default Contact/Product IDs
These are up to your app logic — you can either create them manually or list them:
GET https://desk.zoho.com/api/v1/contacts
GET https://desk.zoho.com/api/v1/products
🛠 Sample Axios Requests
Here's how you can make authorized requests to the Zoho Desk API using Axios in a Next.js app:
POST Request Example: Create a Ticket
import axios from "axios";
const createTicket = async () => {
const response = await axios.post(
"https://desk.zoho.com/api/v1/tickets",
{
subject: "Sample Ticket",
contactId: "1234567890",
departmentId: "0987654321",
description: "This is a sample ticket created via API",
},
{
headers: {
Authorization: `Zoho-oauthtoken YOUR_ACCESS_TOKEN`,
},
}
);
console.log(response.data);
};
GET Request Example: Fetch Tickets
import axios from "axios";
const fetchTickets = async () => {
const response = await axios.get("https://desk.zoho.com/api/v1/tickets", {
headers: {
Authorization: `Zoho-oauthtoken YOUR_ACCESS_TOKEN`,
},
});
console.log(response.data);
};
⚙️ Summary
Once your .env
is fully configured, your Next.js app can securely communicate with the Zoho Desk API by:
- Generating access tokens using the refresh token.
- Performing authorized requests for tickets, contacts, and settings.
- Integrating desk features into your workflow or admin dashboard.
For more detailed information, refer to the Zoho Desk API Documentation.
📩 Need Help?
At Jazzed Technology, we specialize in building integrations to help businesses streamline their support stack. Whether you’re using Zoho, Salesforce, or a custom CRM — we’ve got you covered.
👉 Contact us for help integrating Zoho Desk into your platform or any other Web and IT Support needs.