Configuring attributes with custom functions

Use the following procedure and cURL commands to configure custom functions to attributes.

Procedure

  1. Configure an API client with the Manage Attributes entitlement.
  2. Use the following client credentials to obtain an access token.
    curl --location --request POST 'https://{{tenant}}/oidc/endpoint/default/token' \
          --header 'Content-Type: application/x-www-form-urlencoded' \
          --data-urlencode 'grant_type=client_credentials' \
          --data-urlencode 'client_id={{client_id}}' \
          --data-urlencode 'client_secret={{client_secret}}'
  3. Copy the access_token in the JSON response.
  4. Create an attribute with the custom function.
    Similarly, you can update an attribute by using PUT /v1.0/attributes/{attrId}. Notice the function property in the following code example.
    curl --location --request POST 'https://{{tenant}}/v1.0/attributes' \
        --header 'Authorization: Bearer {{access_token}}' \
        --header 'Content-Type: application/json' \
        --data-raw '{
            "name": "echoedUserID",
            "description": " ",
            "scope": "tenant",
            "sourceType": "static",
            "datatype": "string",
            "tags": [
                "sso"
            ],
            "value": "N/A",
            "function": {
                "custom": "hc.GetAsJson(\"https://postman-echo.com/get?foo1=bar1&foo2=bar2&userid=\" + user.id, { \"User-Agent\":\"Something\" }).args.userid"
            }
        }'
  5. Go to the application and configure attribute mappings as needed.