【问题标题】:Using Process.Start(Url) to get the Token response使用 Process.Start(Url) 获取 Token 响应
【发布时间】:2019-12-17 16:36:08
【问题描述】:

我有以下代码,我想通过此代码从浏览器获取令牌。我已经尝试使用 Process.Start(login) 但我不知道如何使用令牌获取响应。总结一下,我想运行我的桌面应用程序,然后打开浏览器,获取用户登录生成的令牌,然后关闭,这样我的应用程序就可以操作来自 Zoho 的数据。有没有办法使用这个解决方案或更好的解决方案解决方案

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);

【问题讨论】:

标签: c# oauth-2.0


【解决方案1】:

有一个 C# 示例 here 演示如何获取浏览器响应。

桌面 OAuth 的理想工作方式如下:

  • 使用推荐的桌面应用流程,即授权代码流程 (PKCE) - 没有客户端密码
  • 通过系统浏览器登录
  • 通过私有 URI 方案或 Loopback Web 服务器接收响应

虽然这可能很难实现 - 另一个常见的选择是使用 Kevin 所说的 Web 视图,尽管这样做存在一些问题:

  • 密码自动填充不起作用
  • 某些提供商 (Google) 会阻止在 Web 视图上登录

如果有帮助,我有一些 detailed desktop write upsonline desktop code sample 可以运行 - 尽管我的示例使用 Javascript 而不是 C#。

【讨论】:

    猜你喜欢
    • 2021-06-12
    • 1970-01-01
    • 2015-04-26
    • 2013-01-20
    • 2018-04-15
    • 1970-01-01
    • 1970-01-01
    • 2016-09-21
    • 1970-01-01
    相关资源
    最近更新 更多