Problem requesting Grant Token with C# desktop application
Greetings,
I'm new Zoho and am looking to use the API via a C# desktop application. I am following the first steps in the following guidelines to request a Grant Token and subsequently request Access and Refresh Tokens:
I have used the API Console to register a Self Client application as there is no user-interface to be dealt with...just a simple retrieval of data in the background.
This is the C# code that I am using to fetch the Grant Token, but unfortunately, it's returning HTML code instead of JSON content containing what looks like Grant Token. Have I missed the mark completely?
Thanks,
Scott
- public void GetZohoGrantToken()
- {
- try
- {
- ServicePointManager.Expect100Continue = true;
- ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
- ServicePointManager.DefaultConnectionLimit = 9999;
- HttpWebRequest GroupsRequest = (HttpWebRequest)WebRequest.Create("https://accounts.zoho.com/oauth/v2/auth?scope=ZohoBooks.fullaccess.all&client_id=1000.993FJS7NKWGHRAPZ71W6IW16GYC1WA&response_type=code&redirect_uri=http://www.zoho.com/books&access_type=offline");
- GroupsRequest.AllowAutoRedirect = true;
- GroupsRequest.ContentType = "application/json";
- GroupsRequest.Accept = "*/*";
- GroupsRequest.Method = "GET";
-
- WebResponse GroupsResponse = GroupsRequest.GetResponse();
- Stream GroupsDataStream = GroupsResponse.GetResponseStream();
- StreamReader GroupsDataStreamReader = new StreamReader(GroupsDataStream);
- string GroupsContentFromServer = GroupsDataStreamReader.ReadToEnd();
- Console.WriteLine(GroupsContentFromServer);
- GroupsDataStreamReader.Close();
- GroupsDataStreamReader = null;
- GroupsResponse.Close();
- GroupsResponse = null;
- GroupsRequest = null;
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.InnerException);
- }
- }