Chilkat Online Tools

SQL Server / Auth0 Management API / Update a client

Back to Collection Items

-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    -- Important: Do not use nvarchar(max).  See the warning about using nvarchar(max).
    DECLARE @sTmp0 nvarchar(4000)
    -- This example assumes the Chilkat API to have been previously unlocked.
    -- See Global Unlock Sample for sample code.

    DECLARE @http int
    -- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

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

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

    -- {
    --   "name": "",
    --   "client_secret": "",
    --   "logo_uri": "",
    --   "callbacks": [
    --     ""
    --   ],
    --   "allowed_origins": [
    --     ""
    --   ],
    --   "client_aliases": [
    --     ""
    --   ],
    --   "allowed_clients": [
    --     ""
    --   ],
    --   "allowed_logout_urls": [
    --     ""
    --   ],
    --   "jwt_configuration": {
    --     "lifetime_in_seconds": 0,
    --     "secret_encoded": true,
    --     "scopes": {},
    --     "alg": ""
    --   },
    --   "encryption_key": {
    --     "pub": "",
    --     "cert": "",
    --     "subject": ""
    --   },
    --   "sso": true,
    --   "custom_login_page_on": true,
    --   "token_endpoint_auth_method": "",
    --   "app_type": "",
    --   "is_first_party": true,
    --   "custom_login_page": "",
    --   "custom_login_page_preview": "",
    --   "form_template": "",
    --   "addons": {
    --     "aws": {},
    --     "azure_blob": {},
    --     "azure_sb": {},
    --     "rms": {},
    --     "mscrm": {},
    --     "slack": {},
    --     "box": {},
    --     "cloudbees": {},
    --     "concur": {},
    --     "dropbox": {},
    --     "echosign": {},
    --     "egnyte": {},
    --     "firebase": {},
    --     "newrelic": {},
    --     "office365": {},
    --     "salesforce": {},
    --     "salesforce_api": {},
    --     "salesforce_sandbox_api": {},
    --     "samlp": {},
    --     "layer": {},
    --     "sap_api": {},
    --     "sharepoint": {},
    --     "springcm": {},
    --     "wams": {},
    --     "wsfed": {},
    --     "zendesk": {},
    --     "zoom": {}
    --   },
    --   "resource_servers": [
    --     {
    --       "identifier": "",
    --       "scopes": [
    --         ""
    --       ]
    --     }
    --   ],
    --   "client_metadata": {},
    --   "mobile": {
    --     "android": {},
    --     "ios": {}
    --   }
    -- }

    DECLARE @json int
    -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @json OUT

    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'name', ''
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'client_secret', ''
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'logo_uri', ''
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'callbacks[0]', ''
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'allowed_origins[0]', ''
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'client_aliases[0]', ''
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'allowed_clients[0]', ''
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'allowed_logout_urls[0]', ''
    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'jwt_configuration.lifetime_in_seconds', 0
    EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'jwt_configuration.secret_encoded', 1
    EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'jwt_configuration.scopes'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'jwt_configuration.alg', ''
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'encryption_key.pub', ''
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'encryption_key.cert', ''
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'encryption_key.subject', ''
    EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'sso', 1
    EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'custom_login_page_on', 1
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'token_endpoint_auth_method', ''
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'app_type', ''
    EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'is_first_party', 1
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'custom_login_page', ''
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'custom_login_page_preview', ''
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'form_template', ''
    EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'addons.aws'
    EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'addons.azure_blob'
    EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'addons.azure_sb'
    EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'addons.rms'
    EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'addons.mscrm'
    EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'addons.slack'
    EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'addons.box'
    EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'addons.cloudbees'
    EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'addons.concur'
    EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'addons.dropbox'
    EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'addons.echosign'
    EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'addons.egnyte'
    EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'addons.firebase'
    EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'addons.newrelic'
    EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'addons.office365'
    EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'addons.salesforce'
    EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'addons.salesforce_api'
    EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'addons.salesforce_sandbox_api'
    EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'addons.samlp'
    EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'addons.layer'
    EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'addons.sap_api'
    EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'addons.sharepoint'
    EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'addons.springcm'
    EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'addons.wams'
    EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'addons.wsfed'
    EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'addons.zendesk'
    EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'addons.zoom'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'resource_servers[0].identifier', ''
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'resource_servers[0].scopes[0]', ''
    EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'client_metadata'
    EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'mobile.android'
    EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'mobile.ios'

    -- Adds the "Authorization: Bearer {{auth0_token}}" header.
    EXEC sp_OASetProperty @http, 'AuthToken', '{{auth0_token}}'
    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Content-Type', 'application/json'

    DECLARE @sbRequestBody int
    -- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbRequestBody OUT

    EXEC sp_OAMethod @json, 'EmitSb', @success OUT, @sbRequestBody

    DECLARE @resp int
    EXEC sp_OAMethod @http, 'PTextSb', @resp OUT, 'PATCH', 'https://{{auth0_domain}}/api/v2/clients/:id', @sbRequestBody, 'utf-8', 'application/json', 0, 0
    EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
    IF @iTmp0 = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @json
        EXEC @hr = sp_OADestroy @sbRequestBody
        RETURN
      END

    EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
    PRINT @iTmp0
    EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
    PRINT @sTmp0
    EXEC @hr = sp_OADestroy @resp


    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @json
    EXEC @hr = sp_OADestroy @sbRequestBody


END
GO

Curl Command

curl -X PATCH
	-H "Authorization: Bearer {{auth0_token}}"
	-H "Content-Type: application/json"
	-d '{
  "name": "",
  "client_secret": "",
  "logo_uri": "",
  "callbacks": [
    ""
  ],
  "allowed_origins": [
    ""
  ],
  "client_aliases": [
    ""
  ],
  "allowed_clients": [
    ""
  ],
  "allowed_logout_urls": [
    ""
  ],
  "jwt_configuration": {
    "lifetime_in_seconds": 0,
    "secret_encoded": true,
    "scopes": {},
    "alg": ""
  },
  "encryption_key": {
    "pub": "",
    "cert": "",
    "subject": ""
  },
  "sso": true,
  "custom_login_page_on": true,
  "token_endpoint_auth_method": "",
  "app_type": "",
  "is_first_party": true,
  "custom_login_page": "",
  "custom_login_page_preview": "",
  "form_template": "",
  "addons": {
    "aws": {},
    "azure_blob": {},
    "azure_sb": {},
    "rms": {},
    "mscrm": {},
    "slack": {},
    "box": {},
    "cloudbees": {},
    "concur": {},
    "dropbox": {},
    "echosign": {},
    "egnyte": {},
    "firebase": {},
    "newrelic": {},
    "office365": {},
    "salesforce": {},
    "salesforce_api": {},
    "salesforce_sandbox_api": {},
    "samlp": {},
    "layer": {},
    "sap_api": {},
    "sharepoint": {},
    "springcm": {},
    "wams": {},
    "wsfed": {},
    "zendesk": {},
    "zoom": {}
  },
  "resource_servers": [
    {
      "identifier": "",
      "scopes": [
        ""
      ]
    }
  ],
  "client_metadata": {},
  "mobile": {
    "android": {},
    "ios": {}
  }
}'
https://{{auth0_domain}}/api/v2/clients/:id

Postman Collection Item JSON

{
  "name": "Update a client",
  "request": {
    "method": "PATCH",
    "header": [
      {
        "key": "Authorization",
        "value": "Bearer {{auth0_token}}"
      },
      {
        "key": "Content-Type",
        "value": "application/json"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\r\n  \"name\": \"\",\r\n  \"client_secret\": \"\",\r\n  \"logo_uri\": \"\",\r\n  \"callbacks\": [\r\n    \"\"\r\n  ],\r\n  \"allowed_origins\": [\r\n    \"\"\r\n  ],\r\n  \"client_aliases\": [\r\n    \"\"\r\n  ],\r\n  \"allowed_clients\": [\r\n    \"\"\r\n  ],\r\n  \"allowed_logout_urls\": [\r\n    \"\"\r\n  ],\r\n  \"jwt_configuration\": {\r\n    \"lifetime_in_seconds\": 0,\r\n    \"secret_encoded\": true,\r\n    \"scopes\": {},\r\n    \"alg\": \"\"\r\n  },\r\n  \"encryption_key\": {\r\n    \"pub\": \"\",\r\n    \"cert\": \"\",\r\n    \"subject\": \"\"\r\n  },\r\n  \"sso\": true,\r\n  \"custom_login_page_on\": true,\r\n  \"token_endpoint_auth_method\": \"\",\r\n  \"app_type\": \"\",\r\n  \"is_first_party\": true,\r\n  \"custom_login_page\": \"\",\r\n  \"custom_login_page_preview\": \"\",\r\n  \"form_template\": \"\",\r\n  \"addons\": {\r\n    \"aws\": {},\r\n    \"azure_blob\": {},\r\n    \"azure_sb\": {},\r\n    \"rms\": {},\r\n    \"mscrm\": {},\r\n    \"slack\": {},\r\n    \"box\": {},\r\n    \"cloudbees\": {},\r\n    \"concur\": {},\r\n    \"dropbox\": {},\r\n    \"echosign\": {},\r\n    \"egnyte\": {},\r\n    \"firebase\": {},\r\n    \"newrelic\": {},\r\n    \"office365\": {},\r\n    \"salesforce\": {},\r\n    \"salesforce_api\": {},\r\n    \"salesforce_sandbox_api\": {},\r\n    \"samlp\": {},\r\n    \"layer\": {},\r\n    \"sap_api\": {},\r\n    \"sharepoint\": {},\r\n    \"springcm\": {},\r\n    \"wams\": {},\r\n    \"wsfed\": {},\r\n    \"zendesk\": {},\r\n    \"zoom\": {}\r\n  },\r\n  \"resource_servers\": [\r\n    {\r\n      \"identifier\": \"\",\r\n      \"scopes\": [\r\n        \"\"\r\n      ]\r\n    }\r\n  ],\r\n  \"client_metadata\": {},\r\n  \"mobile\": {\r\n    \"android\": {},\r\n    \"ios\": {}\r\n  }\r\n}"
    },
    "url": {
      "raw": "https://{{auth0_domain}}/api/v2/clients/:id",
      "protocol": "https",
      "host": [
        "{{auth0_domain}}"
      ],
      "path": [
        "api",
        "v2",
        "clients",
        ":id"
      ],
      "variable": [
        {
          "key": "id",
          "type": "any"
        }
      ]
    },
    "description": "<strong>Important:</strong> The <code>client_secret</code> and <code>encryption_key</code> attributes can only be updated with the <code>update:client_keys</code> scope."
  },
  "response": [
  ]
}