Generating the Grant Token

Generating the Grant Token

Generating the Grant Token (The Authorization Request)

Once your application is registered, the next step is to obtain a Grant Token (also known as an Authorization Code). This is a short-lived token (valid for only 1 minute) that you will later exchange for permanent access.

At Kalki LLP, we emphasize that this step requires a browser interface, as the user must manually log in and click "Accept" to authorize the integration.


1. Constructing the Authorization URL

You must redirect the user to the Zoho Authorization endpoint. The URL structure varies by data center:

Required Query Parameters

Your request URL must include these specific parameters:

ParameterValue / DescriptionImportance
scopee.g., ZohoBooks.fullaccess.allDefines the permissions requested.
client_idYour Generated Client IDIdentifies your app to Zoho.
response_typecodeTells Zoho to return a Grant Token.
redirect_uriYour Registered Redirect URLMust match your Step 1 registration exactly.
access_typeoffline or onlineUse offline to receive a Refresh Token.
promptconsentForces the consent screen to appear (useful for debugging).

Example URL for Kalki LLP Developers:

https://accounts.zoho.in/oauth/v2/auth?scope=ZohoBooks.fullaccess.all&client_id=1000.XXXXX&response_type=code&redirect_uri=https://kalkillp.com/callback&access_type=offline


When the user visits this URL:

  1. They are prompted to log into their Zoho Account.

  2. A screen appears listing the requested scopes (e.g., "This app wants to view and manage your Zoho Books data").

  3. The user clicks Accept or Deny.


3. The Redirect Response (Capturing the Code)

After the user clicks Accept, Zoho redirects them back to your redirect_uri with the code attached to the URL:

Success Response:

https://kalkillp.com/callback?code=1000.efg123...&location=in&accounts-server=https://accounts.zoho.in

  • code: This is your Grant Token. Save it immediately!

  • location: Confirms the data center (e.g., in for India).

Error Response:

If the user clicks Deny, they are redirected with an error:

https://kalkillp.com/callback?error=access_denied


4. Troubleshooting Step 2: Common Error Logs

Error Code / LogReasonSolution
invalid_clientIncorrect Client ID.Double-check the ID in your API Console.
redirect_uri_mismatchThe URL in the request doesn't match Step 1.Ensure protocols (http vs https) and trailing slashes match.
invalid_scopeTypo in the scope name.Ensure you use ZohoBooks.fullaccess.all (case sensitive).
Code Expires (60s)You waited too long to use the code.The Grant Token must be exchanged for an Access Token within 1 minute.

5. Pro-Tip: The "Self-Client" Shortcut

If you are building a small script for internal use at Kalki LLP and don't want to build a redirect page, use the Self-Client option in the Zoho API Console:

  1. Go to the Generate Code tab in your Self-Client.

  2. Enter your scopes and set an expiry time.

  3. Zoho will provide the code directly in the browser—no redirect URL needed.


Need a Custom OAuth Handler?

Building a seamless "Connect to Zoho Books" button for your website can be tricky. Kalki LLP provides pre-built OAuth handlers in PHP, Python, and Node.js to help you skip the frustration.

    • Related Articles

    • Generating Access and Refresh Tokens

      Generating Access and Refresh Tokens In this step, your server makes a secure back-end request to Zoho's authorization server. Unlike Step 2, this is a POST request that happens entirely behind the scenes—no user interaction is required. At Kalki ...
    • Refreshing Your Access Token

      Refreshing Your Access Token (Automating the Handshake) An Access Token is like a temporary pass—it expires after one hour. To maintain a continuous connection between your software and Zoho Books without asking the user to log in again, you must use ...
    • Guide to Zoho Books OAuth 2.0

      The Ultimate Guide to Zoho Books OAuth 2.0: Setup, Scopes, and Troubleshooting Authentication is the foundation of any secure integration. The Zoho Books API v3 uses the OAuth 2.0 protocol to ensure that your financial data is accessed securely ...
    • Zoho Books API v3: Retrieving Unused Retainer Payments

      Zoho Books API v3: Retrieving Unused Retainer Payments The Get Unused Retainer Payments API returns a list of all retainer payments associated with a specific contact that have a remaining balance. This is essential for workflows where you want to ...
    • Zoho Books API v3: The Complete Error Code & Troubleshooting Guide

      Zoho Books API v3: The Complete Error Code & Troubleshooting Guide In the world of API integration, errors are inevitable. Whether it's a validation slip or a rate limit breach, understanding how to read Zoho's error logs is the difference between a ...