【发布时间】:2020-03-12 21:39:57
【问题描述】:
我正在尝试构建一个 C# dotnetcore 控制台应用程序来与使用 OAuth2 进行授权的 api 交互。我还没有完全弄清楚如何将它用于 C# 控制台应用程序,甚至是不打算让用户登录的库。这可能吗?
到目前为止,我得到以下内容:
private static string _auth_url = "https://idp.bexio.com/authorize";
private static string _token_url = "https://idp.bexio.com/token";
private static string _callback_url = "https://www.myurl.com";
private static string _scope = "monitoring_show";
private static string _client_id = "myid";
private static string _client_secret = "mysecret";
static void Main(string[] args)
{
//request token
var restclient = new RestClient(_auth_url);
RestRequest request = new RestRequest("request/oauth") {Method = Method.POST};
request.AddHeader("Accept", "application/json");
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.AddParameter("client_id", _client_id);
request.AddParameter("client_secret", _client_secret);
request.AddParameter("grant_type", "client_credentials");
var tResponse = restclient.Execute(request);
var responseJson = tResponse.Content;
}
我不知道如何获得授权令牌并提供我需要的所有信息。有人可以告诉我我缺少什么吗?
https://docs.bexio.com/#section/Authentication/Authorization-Code-Flow
【问题讨论】:
标签: c# oauth-2.0 restsharp bexio