USB Connect LPWA - HTTP Bearer Authentication
The following documentation describes how you can use Bearer Autorisation tokens with HTTP and which AT commands you have to use. As a starting point we use https://httpbin.org/
// Set verbose error result codes.
AT+CMEE=2
OK
// Reset the HTTP profile #0
AT+UHTTP=0
OK
// Set the server domain name
AT+UHTTP=0,1,"httpbin.org"
OK
// Set the port of the HTTP request to 80
AT+UHTTP=0,5,80
OK
// Add custom request headers
AT+UHTTP=0,9,"1:Authorization:Bearer MY_TOKEN"
OK
// Submit a get command in text format and store the answer in result.txt
AT+UHTTPC=0,1,"/bearer","result.txt"
OK
# Wait of URC
+UUHTTPCR: 0,1,1
// Check the server response
AT+URDFILE="result.txt"
+URDFILE: "result.txt",276,"HTTP/1.1 200 OK
Date: Wed, 23 Oct 2024 16:27:59 GMT
Content-Type: application/json
Content-Length: 52
Connection: close
Server: gunicorn/19.9.0
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
{
"authenticated": true,
"token": "MY_TOKEN"
}
"
OK