标签: bexio

控制台应用程序中的 OAuth2 访问令牌

我正在尝试构建一个 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 = …
Run Code Online (Sandbox Code Playgroud)

c# restsharp oauth-2.0 bexio

6
推荐指数
1
解决办法
8387
查看次数

标签 统计

bexio ×1

c# ×1

oauth-2.0 ×1

restsharp ×1