HTTP Authentication fails when using config with username, password entry
Posted: Tue Aug 28, 2018 8:38 am
Hello,
I'm using ESP32 DevKitC and try to implement http basic authentication.
The example code of ESP HTTP Client Example works fine.
It accesses a HTTP basic authentication by prepending username:password@ to the hostname in the URL .
However, use of the format "user:password" in the userinfo field is deprecated by RFC 3986.
So I try to use config authentication example with username, password entry instead, like following:
It is the same as the API document of esp-idf.
https://esp-idf.readthedocs.io/zh_CN/la ... word-entry
But no luck with this config, the module would send the http request without "Authorization" filed in the header.
I'm using the lasted esp-idf.
Could you help to check this?
Thanks!
I'm using ESP32 DevKitC and try to implement http basic authentication.
The example code of ESP HTTP Client Example works fine.
It accesses a HTTP basic authentication by prepending username:password@ to the hostname in the URL .
Code: Select all
esp_http_client_config_t config = {
.url = "http://user:passwd@httpbin.org/basic-auth/user/passwd",
.event_handler = _http_event_handler,
.auth_type = HTTP_AUTH_TYPE_BASIC,
};
So I try to use config authentication example with username, password entry instead, like following:
Code: Select all
esp_http_client_config_t config = {
.url = "http://httpbin.org/basic-auth/user/passwd",
.username = "user",
.password = "passwd",
.auth_type = HTTP_AUTH_TYPE_BASIC,
};
https://esp-idf.readthedocs.io/zh_CN/la ... word-entry
But no luck with this config, the module would send the http request without "Authorization" filed in the header.
I'm using the lasted esp-idf.
Could you help to check this?
Thanks!