diff --git a/cpp/lib/Authenticator.cpp b/cpp/lib/Authenticator.cpp index 86585ceeaf..93e2ee39f5 100644 --- a/cpp/lib/Authenticator.cpp +++ b/cpp/lib/Authenticator.cpp @@ -146,12 +146,6 @@ extern "C" { snowflake_cJSON_DeleteItemFromObject(data, "AUTHENTICATOR"); snowflake_cJSON_DeleteItemFromObject(data, "TOKEN"); - if (AUTH_OAUTH == getAuthenticatorType(conn->authenticator)) - { - snowflake_cJSON_AddStringToObject(body, "AUTHENTICATOR", SF_AUTHENTICATOR_OAUTH); - snowflake_cJSON_AddStringToObject(body, "TOKEN", conn->oauth_token); - } - if (!conn || !conn->auth_object) { return; @@ -160,7 +154,6 @@ extern "C" { try { jsonObject_t picoBody; - cJSON* data = snowflake_cJSON_GetObjectItem(body, "data"); cJSONtoPicoJson(data, picoBody); static_cast(conn->auth_object)-> updateDataMap(picoBody); diff --git a/lib/connection.c b/lib/connection.c index 1f3725172e..2d14095d9a 100644 --- a/lib/connection.c +++ b/lib/connection.c @@ -199,6 +199,13 @@ cJSON *STDCALL create_auth_json_body(SF_CONNECT *sf, // update authentication information to body auth_update_json_body(sf, body); + if (AUTH_OAUTH == getAuthenticatorType(sf->authenticator)) + { + data = snowflake_cJSON_GetObjectItem(body, "data"); + snowflake_cJSON_AddStringToObject(data, "AUTHENTICATOR", SF_AUTHENTICATOR_OAUTH); + snowflake_cJSON_AddStringToObject(data, "TOKEN", sf->oauth_token); + } + return body; }