Append Basic Authentications
Dependencies: C12832 HTTPClient LM75B SNICInterface mbed-rtos mbed
Fork of kintone-POST by
Diff: main.cpp
- Revision:
- 3:57ffcb4c9f5d
- Parent:
- 2:de803d46330e
- Child:
- 4:2731edb619b9
--- a/main.cpp Thu Aug 24 02:13:46 2017 +0000 +++ b/main.cpp Thu Aug 31 00:46:34 2017 +0000 @@ -1,6 +1,7 @@ #define POST_URL "https://{subdomain}.cybozu.com/k/v1/record.json" -#define APP_ID xxx +#define APP_ID 999 #define API_TOKEN "xxx" +#define BASIC64 "xxx" #define DEMO_AP_SSID "xxx" #define DEMO_AP_SECUTIRY_KEY "xxx" @@ -43,10 +44,18 @@ char post_template[] = "{\"app\": %i, \"record\": {\"temp\": {\"value\": \"%.1f\"}}}\n"; char header_template[] = "X-Cybozu-API-Token: %s\nContent-Type: application/json\n"; + char header_template_basic[] = "Authorization:Basic %s\nX-Cybozu-API-Token: %s\nContent-Type: application/json\n"; char post_data[256]; char header_data[256]; + + // Basic Authentications + if (BASIC64 != "") { + sprintf(header_data, header_template_basic, BASIC64, API_TOKEN); + header_template[0] = header_template_basic[0]; + } else { + sprintf(header_data, header_template, API_TOKEN); + } sprintf(post_data, post_template, APP_ID, (float)sensor); - sprintf(header_data, header_template, API_TOKEN); HTTPText outText(post_data, strlen(post_data));