1

I have the following code and With this code I would like to get the token from the browser. I already tried to using Process.Start(login) but I don't know how to get the response with the token. Summarizing, I would like to run my desktop application, then the browser open, get the token generated by the user login, and then close, so my application can manipulate the data from Zoho.Is there a way to use this solution or one better solution for it

string scope = "ZohoProjects.projects.READ";
string responseType = "code";
string client_id = "100*****H";
string scrt = "02d1********3";
string state = "testing";
string redirect_uri = "https://www.getpostman.com/oauth2/callback";
string login = $"https://accounts.zoho.com/oauth/v2/auth?scope={scope}&client_id={client_id}&response_type=code&access_type=online&redirect_uri={redirect_uri}&prompt=consent";

RestClient client = new RestClient(login);

RestRequest request = new RestRequest(Method.POST);
var response =  client.Execute(request);
Martin
  • 16,093
  • 1
  • 29
  • 48
  • There are a few solutions (https://stackoverflow.com/questions/27930226/using-oauth-2-with-desktop-c-sharp-application), but if you can it would be easier to embed a WebView directly in your application – Kevin Gosse Dec 16 '19 at 15:11
  • can you use any database(**SQL, MYSql**). – Ravi Kant Singh Dec 17 '19 at 11:04

1 Answers1

0

There is a C# sample here which demonstrates getting a browser response.

Desktop OAuth ideally works as follows:

  • Use the recommended flow for a desktop app, which is Authorization Code Flow (PKCE) - there is no client secret
  • Login via the system browser
  • Receive the response via a Private URI Scheme or Loopback Web Server

This can be tricky to implement though - and another common option is to use a web view as Kevin says, though there are a couple of problems with that:

  • Password autofill won't work
  • Some providers (Google) will block logins on a web view

If it helps I have some detailed desktop write ups and an online desktop code sample that you can run - though my samples are in Javacscript and not C#.

Gary Archer
  • 22,534
  • 2
  • 12
  • 24