I'm trying to integrate a mkr1000 to authenticate against auth0 M2M to retrieve a token for posting weather data to a nodes server.

The POST query works just fine when using cURL, Postman and so on. This confirms that the JWT I'm getting from auth0 and parsing on the nodes server are working correctly.

Where I'm struggling is making the mkr1000 https post request to the service to obtain the token. Auth0 is bouncing back with a "400 Bad Request"

What I'm trying to do is have the mkr1000 post to the weather server with the last JWT received by auth0, if the token is not valid anymore have the IoT(mkr1000) device request for a new token from auth0 and then POST to the nodes weather server.

I'm using the arduinobearssl/WiFISSLClient example.

  • Updated the Arduino IDE to 1.8.16
  • updated the wifi101 library to 0.16.1
  • flashed the wifi101 firmware to 19.6.1
  • added the domain certificate after the upgrade

I'm suspecting that is bouncing me because of an invalide TLS/SSL format in my request. I'm exploring ECCx08 features the crypto chip part of the arduino board but I don't understand how I can setup the board to provide a proper/valid certificate on the TLS layer that oauth0 will accept.

Any hints or suggestions on how to provide valid certs would be very welcome.

#include <SPI.h>
#include <WiFi101.h>
#include <ArduinoECCX08.h>
#include <ArduinoBearSSL.h>

char ssid[] = "mywifi"; 
char pass[] = "mywifipwd"; 
int keyIndex = 0; 

int status = WL_IDLE_STATUS;
char server[] = ""; 

WiFiClient client;
BearSSLClient sslClient(client);

unsigned long getTime() {
  return WiFi.getTime();

void setup() {
  //Initialize serial and wait for port to open:

  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue:
    while (true);

  // attempt to connect to WiFi network:
  while (status != WL_CONNECTED) {
    status = WiFi.begin(ssid, pass);
    // wait 10 seconds for connection:


  Serial.println("\nStarting connection to server...");
  // if you get a connection, report back via serial:
  if (sslClient.connect(server, 443)) {
    Serial.println("connected to server");
    // Make a HTTP request:
    sslClient.println("POST /oauth/token HTTP/1.1");
    sslClient.println("Content-Type: application/json");
    sslClient.println("Connection: close");

void loop() {
  // if there are incoming bytes available
  // from the server, read them and print them:
  while (sslClient.available()) {
    char c =;

  // if the server's disconnected, stop the client:
  if (!sslClient.connected()) {
    Serial.println("disconnecting from server.");

    // do nothing forevermore:
    while (true);

void printWiFiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.println(" dBm");

The response

<head><title>400 Bad Request</title></head>
<center><h1>400 Bad Request</h1></center>


This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.