Ready to build JWT

This commit is contained in:
2024-09-21 20:16:44 +02:00
parent 5db7593a4f
commit 561c49226b
5 changed files with 58 additions and 2 deletions

@ -10,6 +10,7 @@
#include "dev_name.h"
#include "storage.h"
#include "http_client.h"
#include "jwt.h"
#include "esp_log.h"
@ -196,6 +197,27 @@ char *secure_api_get_dev_certificate()
void *secure_api_sync_device()
{
cJSON *obj = cJSON_CreateObject();
if (!obj)
{
ESP_LOGE(TAG, "Failed allocate memory to store JSON object!");
return NULL;
}
cJSON_AddItemToObject(obj, "info", genDevInfo());
char *encoded_req = jwt_gen(obj);
cJSON_Delete(obj);
if (!encoded_req)
{
ESP_LOGE(TAG, "Failed to encode JWT!");
return NULL;
}
printf("JWT: %s\n", encoded_req);
free(encoded_req);
printf("here implement sync device logic\n");
return NULL;
}