2

I am trying to follow Zoho's guide for getting authorized via OAuth. Unfortunately, the guide seems a little outdated as the API Console doesnt look like the screen shots provided in the guide.

This is what I am trying to accomplish

I'm developing a windows client application. So naturally i chose the Non-Browser Application for my zoho client (in the API Console). Using this client type there is no "Authorized Redirect URIs".

So how am i supposed to get authorized to start using the Zoho APIs?

Currently, i've tried various client types w/ various redirect uris (bogus). I am getting an http code response of 500.

I am basically calling an HttpClient GetAsync(requestUrl ) where requestUrl is defined below:

var scopeValue = $"{scope}&client_id={clientId}&client_secret={secret}&response_type=code&access_type=offline";
var requestUrl = $"https://accounts.zoho.com/oauth/v2/auth?scope={scopeValue}";

Question

  • Why am i getting a 500 error when i invoke this GET request to get authorized?
  • Am I choosing/configuring the wrong zoho client type?
  • Is there a difference between a Zoho Account Id and User Id (this MIGHT be one of my problems)?

Just for FYI, here is the Zoho API Console with the various client types to choose from:

enter image description here

AlvinfromDiaspar
  • 6,611
  • 13
  • 75
  • 140

1 Answers1

3

Try going to a different requestUrl. I believe you should be going here. You should also be using a POST request. I chose the Non-Browser Application for my zoho client (in the API Console). And I am able to get a response.

https://accounts.zoho.com/oauth/v3/device/code?client_id=xxxx&scope=ZohoProjects.tasklists.READ&grant_type=device_request

I wrote this in VBA only for trouble shooting this question.

    Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
    Url = "https://accounts.zoho.com/oauth/v3/device/code?" & _
        "client_id=xxx&" & _
        "scope=ZohoProjects.tasklists.READ&" & _
        "grant_type=device_request"
    objHTTP.Open "POST", Url, False
    objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    objHTTP.Send ("")

    replyTXT = objHTTP.responseText
    Debug.Print (replyTXT)

I believe this link has some helpful information. https://www.zoho.com/accounts/protocol/oauth/devices/initiation-request.html

Nicholas Stom
  • 322
  • 1
  • 3
  • 10
  • Awesome. This is working for me as well! Does this mean i can just use the device_code as my auth token? – AlvinfromDiaspar Mar 24 '22 at 07:47
  • Also, i want to ultimately call the Folders API. Should i use the device_code for the accountId for this API? https://www.zoho.com/mail/help/api/get-all-folder-details.html – AlvinfromDiaspar Mar 24 '22 at 08:05
  • 1
    @AlvinfromDiaspar I think you need to get your device code, then do a polling request to get your access token. Then you have client Id, client secret, and access token. Read this documentation. https://www.zoho.com/accounts/protocol/oauth/devices/polling-request.html – Nicholas Stom Mar 24 '22 at 13:58
  • I was able to obtain the access token finally. Im trying to get all of my Folders via the Folders API. I have the Authorization w/ token added to the headers. i am now getting this error: {"data":{"errorCode":"URL_RULE_NOT_CONFIGURED"},"status":{"code":404,"description":"Invalid Input"}} – AlvinfromDiaspar Mar 24 '22 at 16:55
  • My request url was wrong. Instead of accountId i was using clientId. After changing this to my accountId (same thing a userId ?), i am now getting an error that my "account does not exist". – AlvinfromDiaspar Mar 24 '22 at 17:04
  • Nicholas, do you know how to obtain an access token for Client Based Applications? I am now creating a ReactJS web app. And i keep getting a fetch failed type of error when requesting an access token. Im following this zoho doc for this. https://www.zoho.com/accounts/protocol/oauth/js-apps/access-token.html – AlvinfromDiaspar Aug 14 '22 at 06:24