Chilkat Online Tools

unicodeC / Auth0 Management API / Update tenant settings

Back to Collection Items

#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkHttpResponseW.h>

void ChilkatSample(void)
    {
    HCkHttpW http;
    BOOL success;
    HCkJsonObjectW json;
    HCkStringBuilderW sbRequestBody;
    HCkHttpResponseW resp;

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    http = CkHttpW_Create();

    // Use this online tool to generate code from sample JSON: Generate Code to Create JSON

    // The following JSON is sent in the request body.

    // {
    //   "change_password": {
    //     "enabled": true,
    //     "html": ""
    //   },
    //   "guardian_mfa_page": {
    //     "enabled": true,
    //     "html": ""
    //   },
    //   "error_page": {
    //     "html": "",
    //     "show_log_link": true,
    //     "url": ""
    //   },
    //   "flags": {
    //     "change_pwd_flow_v1": true,
    //     "enable_client_connections": true,
    //     "enable_apis_section": true,
    //     "enable_pipeline2": true
    //   },
    //   "friendly_name": "",
    //   "picture_url": "",
    //   "support_email": "",
    //   "support_url": "",
    //   "allowed_logout_urls": [
    //     ""
    //   ],
    //   "session_lifetime": 0
    // }

    json = CkJsonObjectW_Create();
    CkJsonObjectW_UpdateBool(json,L"change_password.enabled",TRUE);
    CkJsonObjectW_UpdateString(json,L"change_password.html",L"");
    CkJsonObjectW_UpdateBool(json,L"guardian_mfa_page.enabled",TRUE);
    CkJsonObjectW_UpdateString(json,L"guardian_mfa_page.html",L"");
    CkJsonObjectW_UpdateString(json,L"error_page.html",L"");
    CkJsonObjectW_UpdateBool(json,L"error_page.show_log_link",TRUE);
    CkJsonObjectW_UpdateString(json,L"error_page.url",L"");
    CkJsonObjectW_UpdateBool(json,L"flags.change_pwd_flow_v1",TRUE);
    CkJsonObjectW_UpdateBool(json,L"flags.enable_client_connections",TRUE);
    CkJsonObjectW_UpdateBool(json,L"flags.enable_apis_section",TRUE);
    CkJsonObjectW_UpdateBool(json,L"flags.enable_pipeline2",TRUE);
    CkJsonObjectW_UpdateString(json,L"friendly_name",L"");
    CkJsonObjectW_UpdateString(json,L"picture_url",L"");
    CkJsonObjectW_UpdateString(json,L"support_email",L"");
    CkJsonObjectW_UpdateString(json,L"support_url",L"");
    CkJsonObjectW_UpdateString(json,L"allowed_logout_urls[0]",L"");
    CkJsonObjectW_UpdateInt(json,L"session_lifetime",0);

    // Adds the "Authorization: Bearer {{auth0_token}}" header.
    CkHttpW_putAuthToken(http,L"{{auth0_token}}");
    CkHttpW_SetRequestHeader(http,L"Content-Type",L"application/json");

    sbRequestBody = CkStringBuilderW_Create();
    CkJsonObjectW_EmitSb(json,sbRequestBody);

    resp = CkHttpW_PTextSb(http,L"PATCH",L"https://{{auth0_domain}}/api/v2/tenants/settings",sbRequestBody,L"utf-8",L"application/json",FALSE,FALSE);
    if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkHttpW_Dispose(http);
        CkJsonObjectW_Dispose(json);
        CkStringBuilderW_Dispose(sbRequestBody);
        return;
    }

    wprintf(L"%d\n",CkHttpResponseW_getStatusCode(resp));
    wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));
    CkHttpResponseW_Dispose(resp);


    CkHttpW_Dispose(http);
    CkJsonObjectW_Dispose(json);
    CkStringBuilderW_Dispose(sbRequestBody);

    }

Curl Command

curl -X PATCH
	-H "Authorization: Bearer {{auth0_token}}"
	-H "Content-Type: application/json"
	-d '{
  "change_password": {
    "enabled": true,
    "html": ""
  },
  "guardian_mfa_page": {
    "enabled": true,
    "html": ""
  },
  "error_page": {
    "html": "",
    "show_log_link": true,
    "url": ""
  },
  "flags": {
    "change_pwd_flow_v1": true,
    "enable_client_connections": true,
    "enable_apis_section": true,
    "enable_pipeline2": true
  },
  "friendly_name": "",
  "picture_url": "",
  "support_email": "",
  "support_url": "",
  "allowed_logout_urls": [
    ""
  ],
  "session_lifetime": 0
}'
https://{{auth0_domain}}/api/v2/tenants/settings

Postman Collection Item JSON

{
  "name": "Update tenant settings",
  "request": {
    "method": "PATCH",
    "header": [
      {
        "key": "Authorization",
        "value": "Bearer {{auth0_token}}"
      },
      {
        "key": "Content-Type",
        "value": "application/json"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\r\n  \"change_password\": {\r\n    \"enabled\": true,\r\n    \"html\": \"\"\r\n  },\r\n  \"guardian_mfa_page\": {\r\n    \"enabled\": true,\r\n    \"html\": \"\"\r\n  },\r\n  \"error_page\": {\r\n    \"html\": \"\",\r\n    \"show_log_link\": true,\r\n    \"url\": \"\"\r\n  },\r\n  \"flags\": {\r\n    \"change_pwd_flow_v1\": true,\r\n    \"enable_client_connections\": true,\r\n    \"enable_apis_section\": true,\r\n    \"enable_pipeline2\": true\r\n  },\r\n  \"friendly_name\": \"\",\r\n  \"picture_url\": \"\",\r\n  \"support_email\": \"\",\r\n  \"support_url\": \"\",\r\n  \"allowed_logout_urls\": [\r\n    \"\"\r\n  ],\r\n  \"session_lifetime\": 0\r\n}"
    },
    "url": {
      "raw": "https://{{auth0_domain}}/api/v2/tenants/settings",
      "protocol": "https",
      "host": [
        "{{auth0_domain}}"
      ],
      "path": [
        "api",
        "v2",
        "tenants",
        "settings"
      ]
    }
  },
  "response": [
  ]
}