c# - 使用 RestClient 从 Google Cloud OAuth 提供程序检索访问令牌
问题描述
我一直在尝试使用 RestClient 使用下面的代码(我已经替换了 clientid 和密钥)从 Google Cloud OAuth 中检索访问令牌,但在花费了很多小时后没有运气。由于某些原因,我无法使用 Google 库。在 Google 云中,我在创建 OAuth Api 时创建了桌面应用程序类型。
var client = new RestClient("https://accounts.google.com/o/oauth2/auth");
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/x-www-form-urlencoded");
request.AddParameter("application/x-www-form-urlencoded", "client_id=[123].apps.googleusercontent.com&client_secret=[xyz]&redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code&scope=", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
我收到授权错误,400:invalid_request
请指导我在这里做错了什么......
解决方案
推荐阅读
- tfs - 安装扩展;本地市场
- javascript - 在表格中的新文档中自动填充AngularJS中的值
- scala - 为什么抛出异常时Scala中的原子块会运行两次?
- installation - Wix - 在循环中搜索密钥以进行安装
- php - 我可以保护 html 输入代码吗?
- r - 通过变量运行 ifelse 语句
- python-3.x - Selenium Python:delete_all_cookies() 不会删除所有存储的 cookie
- hyperledger-composer - 在智能合约中使用加密算法
- ios - VoiceOver 正在寻找附近的可访问元素来阅读?
- spss - 如何从两个自变量中创建 4 个条件