From 319a51c37cad1d122fb1fcc6a6afca6016327f18 Mon Sep 17 00:00:00 2001 From: "ethan.du" Date: Fri, 4 Dec 2020 15:04:14 +0800 Subject: [PATCH 1/2] add http auth url --- samples/http/http_client_sample.c | 6 +++--- src/http/http_client.c | 4 ++-- src/sdk-impl/uiot_export.h | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/samples/http/http_client_sample.c b/samples/http/http_client_sample.c index 9968922..b22e2da 100644 --- a/samples/http/http_client_sample.c +++ b/samples/http/http_client_sample.c @@ -26,11 +26,11 @@ #include "utils_httpc.h" #include "uiot_export_http.h" -#define UIOT_MY_PRODUCT_SN "PRODUCT_SN" +#define UIOT_MY_PRODUCT_SN "nvtmx50n2j9nilik" -#define UIOT_MY_DEVICE_SN "DEVICE_SN" +#define UIOT_MY_DEVICE_SN "tlilyffhh3aqi6zx" -#define UIOT_MY_DEVICE_SECRET "DEVICE_SECRET" +#define UIOT_MY_DEVICE_SECRET "l0310dqp3rjciupw" #define UIOT_PUBLISH_TOPIC "%s/%s/upload/event" diff --git a/src/http/http_client.c b/src/http/http_client.c index 3867633..53fcbb5 100644 --- a/src/http/http_client.c +++ b/src/http/http_client.c @@ -21,6 +21,7 @@ #include "lite-utils.h" #include "ca.h" #include "utils_sha2.h" +#include "uiot_export.h" int IOT_HTTP_Get_Token(const char *product_sn, const char *device_sn, const char *device_sercret, char *token) { @@ -87,9 +88,8 @@ int IOT_HTTP_Get_Token(const char *product_sn, const char *device_sn, const char HAL_Snprintf(http_client_post->header, 1024, "Content-Type: application/json\r\nAuthorization: %s\r\nbody: %s\r\n",mac_output_char,http_data_post->post_buf); const char *ca_crt = iot_https_ca_get(); - char *url = (char *)"https://http-cn-sh2.iot.ucloud.cn/auth"; - ret = http_client_common(http_client_post, url, 443, ca_crt, HTTP_POST, http_data_post,5000); + ret = http_client_common(http_client_post, UIOT_AUTH_URL, 443, ca_crt, HTTP_POST, http_data_post,5000); if(SUCCESS_RET != ret) { LOG_ERROR("HTTP_POST error\n"); diff --git a/src/sdk-impl/uiot_export.h b/src/sdk-impl/uiot_export.h index 2434df2..11d2da5 100644 --- a/src/sdk-impl/uiot_export.h +++ b/src/sdk-impl/uiot_export.h @@ -57,14 +57,15 @@ extern "C" { /* MQTT连接域名 */ //上海区域域名 #define UIOT_MQTT_DIRECT_DOMAIN "mqtt-cn-sh2.iot.ucloud.cn" +#define UIOT_AUTH_URL "https://http-cn-sh2.iot.ucloud.cn/auth" #define UIOT_UPLOAD_FILE_URL "https://file-cn-sh2.iot.ucloud.cn/api/v1/url" /* //使用广州区域时替换为 #define UIOT_MQTT_DIRECT_DOMAIN "mqtt-cn-gd.iot.ucloud.cn" +#define UIOT_AUTH_URL "https://http-cn-gd.iot.ucloud.cn/auth" #define UIOT_UPLOAD_FILE_URL "https://file-cn-gd.iot.ucloud.cn/api/v1/url" */ - #include "uiot_export_mqtt.h" #include "uiot_defs.h" From 8ce1ad3684215ad4108246c03ae32bf93d992062 Mon Sep 17 00:00:00 2001 From: ethanDu1 <50894974+ethanDu1@users.noreply.github.com> Date: Fri, 4 Dec 2020 15:05:59 +0800 Subject: [PATCH 2/2] Update http_client_sample.c --- samples/http/http_client_sample.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/http/http_client_sample.c b/samples/http/http_client_sample.c index b22e2da..9968922 100644 --- a/samples/http/http_client_sample.c +++ b/samples/http/http_client_sample.c @@ -26,11 +26,11 @@ #include "utils_httpc.h" #include "uiot_export_http.h" -#define UIOT_MY_PRODUCT_SN "nvtmx50n2j9nilik" +#define UIOT_MY_PRODUCT_SN "PRODUCT_SN" -#define UIOT_MY_DEVICE_SN "tlilyffhh3aqi6zx" +#define UIOT_MY_DEVICE_SN "DEVICE_SN" -#define UIOT_MY_DEVICE_SECRET "l0310dqp3rjciupw" +#define UIOT_MY_DEVICE_SECRET "DEVICE_SECRET" #define UIOT_PUBLISH_TOPIC "%s/%s/upload/event"