我正在MFC框架中构建Git客户端,并且我使用casablanca库来连接github服务器并使用它的API。在Github的教程中,一个示例展示了如何向github服务器发送请求,并附加用户名和密码以进行身份验证:
https://developer.github.com/v3/#authentication
curl -i https://api.github.com -u valid_username:valid_password 现在,我试着用微软的casablanca来达到同样的效果,但我就是不能理解正确的语法:
http_client client(U("https://api.github.com/users/myuser"));
uri_builder builder(U("- u myuser:mypass"));
pplx::task<http_response> requestTask = client.request(methods::GET, builder.to_string()); 在调用这个之后,我得到了从casablanca抛出的异常,说uri无效。
你知道如何在casablanca中正确构造请求,以便我可以将其发送到github服务器吗?
谢谢。
发布于 2016-03-29 05:43:22
在GitHub页面上的示例中,-u username:password是curl的一个选项:
-u/--user <user:password>
Specify the user name and password to use for server authentication.您可以使用http_client_config::set_credentials()通过C++ REST SDK执行基本身份验证。
(另请参阅相关问题:Set Basic HTTP Authentication in Casablanca)
https://stackoverflow.com/questions/36249296
复制相似问题