Open
Description
Basic Infos
- This issue complies with the issue POLICY doc.
- I have read the documentation at readthedocs and the issue is not addressed there.
- I have tested that the issue is present in current master branch (aka latest git).
- I have searched the issue tracker for a similar issue.
- If there is a stack dump, I have decoded it.
- I have filled out all fields below.
Platform
- Hardware: ESP-12F
- Core Version: 2.7.4
- Development Env: Arduino IDE
- Operating System: MacOS
Settings in IDE
- Module: Wemos D1 R2
- Flash Mode: qio
- Flash Size: 4MB
- lwip Variant: v2 Lower Memory
- Reset Method: ck
- Flash Frequency: 40Mhz
- CPU Frequency: 80Mhz
- Upload Using: SERIAL
- Upload Speed: 921600
Problem Description
After checking the source code of the library, it seems that the only way to set the Authorization
header is through the use of either of the 2 setAuthorization
methods (adding the header manually through the addHeader
method does nothing for this header).
However, both of these methods internally set a base64 encoded field, which is then used as Basic
type authentication.
As far as I can see, there is no way to set a Bearer
token to authenticate requests.
MCVE Sketch
#include <Arduino.h>
#include <ESP8266HTTPClient.h>
const char* ssid = "ssid";
const char* password = "pass";
HTTPClient client;
void setup() {
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
}
}
void loop() {
client.begin("http://localhost:5678");
client.setAuthorization("user", "pass"); // Will set _base64Authorization to base64encode(user+ ':' + pass)
client.setAuthorization("base64encoded_String"); // Will set _base64Authorization to the arg value
client.GET(); // Will set the Authorization header to "Basic " + _base64Authorization
}
Debug Messages
No debug messages