【问题标题】:rest post request with chilkat lib使用 chilkat lib 发布请求
【发布时间】:2019-07-05 00:53:25
【问题描述】:

当尝试使用 chilkat 库在 c++ 中实现时,使用 postman 接口的工作发布请求不起作用,使用 postman 我得到响应 200,使用程序我得到 401(未经授权)。 我正在使用 chilkat 的示例来请求休息。

无论您在哪里看到用户名和密码,都会填写有效值。

ckrest休息;

//  Make the initial connection (without sending a request yet).
bool bTls = true;
int port = 443;
bool bAutoReconnect = true;
success = rest.Connect("https://dev-182721.oktapreview.com",port,bTls,bAutoReconnect);
if (success != true) {
    std::cout << rest.lastErrorText() << "\r\n";
    return;
}
rest.put_Authorization("username:password");
rest.authorization();

rest.AddHeader("Content-Type","application/x-www-form-urlencoded");

//  Provide query params.
rest.AddQueryParam("grant_type","password");
rest.AddQueryParam("redirect_uri","http://localhost");
rest.AddQueryParam("username","username");
rest.AddQueryParam("password","password");
rest.AddQueryParam("scope","openid");


const char *responseStr= 
rest.fullRequestFormUrlEncoded("POST","/oauth2/default/v1/token");

if (rest.get_LastMethodSuccess() != true) {
    std::cout << rest.lastErrorText() << "\r\n";
    return;
}

//  When successful, the response status code will equal 200.

谁能帮我弄清楚缺少什么

【问题讨论】:

    标签: c++ rest post access-token chilkat


    【解决方案1】:

    Okta 访问令牌示例可在此处获得:https://www.example-code.com/cpp/okta_oauth_oidc.asp

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-15
      • 2015-02-16
      • 2013-02-22
      • 2015-05-08
      相关资源
      最近更新 更多