使用定制函数配置属性

使用以下过程和 cURL 命令来配置定制函数属性。

过程

  1. 使用该 Manage Attributes 授权配置 API 客户端。

    请参阅 “创建 API 客户端 ”。

  2. 使用以下客户机凭证来获取访问令牌。
    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. 复制 JSON 响应中的 access_token
  4. 使用定制函数创建属性。
    类似,您可以使用 PUT /v1.0/attributes/{attrId} 更新属性。 请注意以下代码示例中的 function 属性。
    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. 转至应用程序并根据需要配置属性映射。