Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http credentials setting gets 401 error #1321

Open
serenity103 opened this issue Feb 5, 2020 · 0 comments
Open

http credentials setting gets 401 error #1321

serenity103 opened this issue Feb 5, 2020 · 0 comments

Comments

@serenity103
Copy link

serenity103 commented Feb 5, 2020

//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");
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

I'm trying to set a credentials through cpprestsdk aka casablanca.

And I've received 401 error which is failed to authenticate user, it means password error.

The server where I wanna send a query is elastic-search's cluster.

Any advice would be thankful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant