//Basic Authorization Setting
http_client_config config;
credentials creds(L"name", L"password");
config.set_credentials(creds);
http_client client(U("http://severip/"), config);
// create header
http_request req(methods::GET);
//// Add base64 result to header
req.headers().add(L"Authorization", L"Basic bmFtZTpwYXNzd29yZA");
req.set_request_uri(L"/_cat/master");
pplx::task<http_response> responses = client.request(req);
pplx::task<web::json::value> jvalue = responses.get().extract_json();
web::json::value v = jvalue.get();
utility::string_t jsonval = v.serialize();
wcout << jsonval << endl;
//with base64 encoding.
//bmFtZTpwYXNzd29yZA = name:password
我正在尝试通过cpprestsdk aka casablanca设置凭据。
我已经收到401错误,无法激活用户,这意味着密码错误。
任何建议将是感激的。
最佳答案
尝试使用curl命令快速验证用户名/密码。
curl -X PUT --basic -u {user}:{password} http://severip/
关于http - cpprestsdk http凭据设置获取401错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60067806/