Chilkat Online Tools

Swift / ForgeRock Identity Cloud Collection / Step 2: Get a Managed Identity

Back to Collection Items

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

    let http = CkoHttp()
    var success: Bool

    let queryParams = CkoJsonObject()
    queryParams.UpdateString("_queryFilter", value: "userName eq \"{{managedUsername}}\"")

    http.SetRequestHeader("X-OpenIDM-Username", value: "{{adminUsername}}")
    http.SetRequestHeader("Accept-API-Version", value: "resource=1.0")
    http.SetRequestHeader("X-OpenIDM-Password", value: "{{adminPassword}}")
    // Adds the "Authorization: Bearer <access_token>" header.
    http.AuthToken = "<access_token>"

    var resp: CkoHttpResponse? = http.QuickRequestParams("GET", url: "https://<tenant-name>.forgeblocks.com/openidm/managed/alpha_user", json: queryParams)
    if http.LastMethodSuccess == false {
        print("\(http.LastErrorText)")
        return
    }

    print("\(resp!.StatusCode.intValue)")
    print("\(resp!.BodyStr)")
    resp = nil

}

Curl Command

curl -G -d "_queryFilter=userName%20eq%20%22%7B%7BmanagedUsername%7D%7D%22"
	-H "Authorization: Bearer <access_token>"
	-H "Accept-API-Version: resource=1.0"
	-H "X-OpenIDM-Username: {{adminUsername}}"
	-H "X-OpenIDM-Password: {{adminPassword}}"
https://<tenant-name>.forgeblocks.com/openidm/managed/alpha_user

Postman Collection Item JSON

{
  "name": "Step 2: Get a Managed Identity",
  "event": [
    {
      "listen": "test",
      "script": {
        "exec": [
          "const jsonData = JSON.parse(responseBody);",
          "if(jsonData._id && jsonData._id != \"\"){",
          "    pm.globals.set(\"managedUserId\", jsonData._id);",
          "}",
          ""
        ],
        "type": "text/javascript"
      }
    }
  ],
  "request": {
    "method": "GET",
    "header": [
      {
        "description": "(Required) ",
        "key": "Accept-API-Version",
        "value": "resource=1.0",
        "disabled": true
      },
      {
        "key": "X-OpenIDM-Username",
        "type": "text",
        "value": "{{adminUsername}}",
        "disabled": true
      },
      {
        "key": "X-OpenIDM-Password",
        "type": "text",
        "value": "{{adminPassword}}",
        "disabled": true
      }
    ],
    "url": {
      "raw": "{{platformUrl}}/openidm/managed/alpha_user?_queryFilter=userName eq \"{{managedUsername}}\"",
      "host": [
        "{{platformUrl}}"
      ],
      "path": [
        "openidm",
        "managed",
        "alpha_user"
      ],
      "query": [
        {
          "key": "_fields",
          "value": "",
          "description": "Optional parameter containing a comma separated list of field references specifying which fields of the targeted JSON resource should be returned.",
          "disabled": true
        },
        {
          "key": "_queryFilter",
          "value": "userName eq \"{{managedUsername}}\""
        }
      ]
    },
    "description": "Obtain the details of a managed identity."
  },
  "response": [
    {
      "name": "Success",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "(Required) ",
            "key": "Accept-API-Version",
            "value": "<string>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/openidm/managed/user#1.0_query_filter?_fields=&_prettyPrint=true&_queryFilter=<string>&_pageSize=<integer>&_totalPagedResultsPolicy=<string>&_sortKeys=<string>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "openidm",
            "managed",
            "user"
          ],
          "hash": "1.0_query_filter?_fields=&_prettyPrint=true&_queryFilter=<string>&_pageSize=<integer>&_totalPagedResultsPolicy=<string>&_sortKeys=<string>"
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "*/*"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}