Chilkat Online Tools

PureBasic / Auth0 Management API / Create a client

Back to Collection Items

IncludeFile "CkJsonObject.pb"
IncludeFile "CkHttp.pb"
IncludeFile "CkHttpResponse.pb"

Procedure ChilkatExample()

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

    http.i = CkHttp::ckCreate()
    If http.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    success.i

    ; 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": [
    ;     ""
    ;   ],
    ;   "token_endpoint_auth_method": "",
    ;   "app_type": "",
    ;   "is_first_party": true,
    ;   "jwt_configuration": {
    ;     "lifetime_in_seconds": 0,
    ;     "secret_encoded": true,
    ;     "scopes": {},
    ;     "alg": ""
    ;   },
    ;   "encryption_key": {
    ;     "pub": "",
    ;     "cert": ""
    ;   },
    ;   "sso": true,
    ;   "custom_login_page_on": true,
    ;   "custom_login_page": "",
    ;   "custom_login_page_preview": "",
    ;   "form_template": "",
    ;   "is_heroku_app": true,
    ;   "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": {}
    ;   }
    ; }

    json.i = CkJsonObject::ckCreate()
    If json.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

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

    ; Adds the "Authorization: Bearer {{auth0_token}}" header.
    CkHttp::setCkAuthToken(http, "{{auth0_token}}")
    CkHttp::ckSetRequestHeader(http,"Content-Type","application/json")

    resp.i = CkHttp::ckPostJson3(http,"https://{{auth0_domain}}/api/v2/clients","application/json",json)
    If CkHttp::ckLastMethodSuccess(http) = 0
        Debug CkHttp::ckLastErrorText(http)
        CkHttp::ckDispose(http)
        CkJsonObject::ckDispose(json)
        ProcedureReturn
    EndIf

    Debug Str(CkHttpResponse::ckStatusCode(resp))
    Debug CkHttpResponse::ckBodyStr(resp)
    CkHttpResponse::ckDispose(resp)



    CkHttp::ckDispose(http)
    CkJsonObject::ckDispose(json)


    ProcedureReturn
EndProcedure

Curl Command

curl -X POST
	-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": [
    ""
  ],
  "token_endpoint_auth_method": "",
  "app_type": "",
  "is_first_party": true,
  "jwt_configuration": {
    "lifetime_in_seconds": 0,
    "secret_encoded": true,
    "scopes": {},
    "alg": ""
  },
  "encryption_key": {
    "pub": "",
    "cert": ""
  },
  "sso": true,
  "custom_login_page_on": true,
  "custom_login_page": "",
  "custom_login_page_preview": "",
  "form_template": "",
  "is_heroku_app": true,
  "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

Postman Collection Item JSON

{
  "name": "Create a client",
  "request": {
    "method": "POST",
    "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  \"token_endpoint_auth_method\": \"\",\r\n  \"app_type\": \"\",\r\n  \"is_first_party\": true,\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  },\r\n  \"sso\": true,\r\n  \"custom_login_page_on\": true,\r\n  \"custom_login_page\": \"\",\r\n  \"custom_login_page_preview\": \"\",\r\n  \"form_template\": \"\",\r\n  \"is_heroku_app\": true,\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",
      "protocol": "https",
      "host": [
        "{{auth0_domain}}"
      ],
      "path": [
        "api",
        "v2",
        "clients"
      ]
    },
    "description": "Creates a new client application. The samples on the right show every attribute that can be used."
  },
  "response": [
  ]
}