Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zoho Invoice API Error {"error":"invalid_client"} while requesting for token

Tags:

zoho

While accessing Zoho api to get the token I'm getting the following error:

{"error":"invalid_client"}

Step 1: I'm requesting for Auth Code and the auth code is returned successfully.

This is the API I'm using. https://accounts.zoho.com/oauth/v2/auth?scope=xxx&client_id=yyyyy&state=zzzz&response_type=code&redirect_uri=pppppp&access_type=offline

Step 2: Token Request With the Auth Code obtained in Step-1 I'm doing a post request for the token at that time only I'm getting the below exception.

var authTokenRequestData = new
{
    code= code,
    client_id= _clientId,
    client_secret =_clientSecret,
    redirect_uri = _redirectUri,
    grant_type = "authorization_code"
};


var data = new StringContent(JsonConvert.SerializeObject(authTokenRequestData), Encoding.UTF8, "application/json");
    
var url = "https://accounts.zoho.com/oauth/v2/token";

string result = "";

using (var client = new HttpClient())
    {
        var response = await client.PostAsync(url, data);
        result = await response.Content.ReadAsStringAsync();
    }

It's giving me the exception

{error:invalid_client}

I've verified my client_id and client_secret. It's correct only.

It's Server-Based-Application client I've registered.

Any help is highly appreciated on this.

like image 751
Ashish Tripathi Avatar asked Oct 31 '25 01:10

Ashish Tripathi


1 Answers

There could be one more reason for this issue.

{"error":"invalid_client"}

Check if you're using the correct domain. (.in .com or...)

For example, you're using .in instead of .com or vice-versa

In my case when I was using .in domain but my domain was .com I was getting the same error {"error":"invalid_client"}

I was using this:

var url = "https://accounts.zoho.in/oauth/v2/token"; 

I replaced it as below and that solved my issue.

var url = "https://accounts.zoho.com/oauth/v2/token";  
like image 144
Ashish Tripathi Avatar answered Nov 03 '25 00:11

Ashish Tripathi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!