Manage Service Identities
    • PDF

    Manage Service Identities

    • PDF

    Article Summary

    This API helps manage service identity tokens.


    1. Create a Service Identity Token 

    The POST method creates a token for a given service identity. The token has the same privileges assigned to the service identity. When this token is created, the old token associated with the identity provider will be removed. 

    An identity provider can have only one token at any given time. The token that is generated will be returned only once.

    POST{{url}}/api/users/{{id}}/tokens

    Request Parameters

    The request parameters used in this method are shown in the following table:

    ParameterDescriptionData TypeRequired
    IDThe ID of the service identity.stringMandatory

    tokenExpirationDays

    The number of days in which token would expire since it was last used.

    The token expiration days can be any value between 1 day and 90 days.

    string

    Mandatory

    Request Example

    An example POST request for creating a service identity token is shown here.

    ShellShell
    curl --location --request POST '{{url}}/api/users/wUGJu578TGXaVtD2EnCW/tokens' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: TOKEN {{token}}' \
    --data-raw '{
        "tokenExpirationDays" : 90
    }'

    Response Example 

    An example response of POST request for creating a service identity token is shown here. 

    Status: 201 Created
    JSONJSON
    {
      "id": "vwgb24vphdgdrewa2qic",
      "name": "wUGJu578TGXaVtD2EnCW",
      "expiresOn": "2021-03-16T05:45:19Z",
      "createdOn": "2020-12-16T05:45:19Z",
      "type": "ServiceIdentity",
      "tokenExpirationDays": 90,
      "lastAccessed": "2020-12-16T05:45:19Z",
      "status": "Active",
      "assignedTo": "wUGJu578TGXaVtD2EnCW",
      "token": "AAA=",
      "createdBy": "user2"
    }

    2. Update Service Identity Token

    The PATCH method updates the token expiration days for an existing service identity token.

    PATCH{{url}}/api/token/{{id}}

    Request Parameters

    The request parameters used in this method are shown in the following table:

    ParameterDescriptionData TypeRequired
    IDThe ID of the service identity.stringMandatory

    tokenExpirationDays

    The number of days in which token would expire since it was last used.

    The token expiration days can be any value between 1 day and 90 days.

    string

    Mandatory

    Request Example

    An example PATCH request for updating a service identity token is shown here.

    ShellShell
    curl --location --request PATCH '{{url}}/api/users/wUGJu728TGXaVtD2EnCW/tokens' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: TOKEN {{token}}' \
    --data-raw '{
        "tokenExpirationDays" : 18
    }'

    Response

    Status: 204 No Content

    The response only has headers.

    Note:

    This request does not return a response body.


    3. Get Service Identity Token Details

    The GET method returns details of the token associated with the service identity.

    GET{{url}}/api/users/{{id}}/tokens

    Request Example

    An example GET request for retrieving the details of a service identity token is shown here.

    ShellShell
    curl --location --request GET '{{url}}/api/users/{{id}}/tokens' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: TOKEN {{token}}'

    Response Example

    An example response of the GET request for retrieving the details of a service identity token is shown here. 

    JSONJSON
    {
        "status": "active",
        "adminRoles": [],
        "type": "ServiceIdentity",
        "created": "2022-02-10T07:05:40Z",
        "modified": "2022-11-29T12:46:18Z",
        "lastLogin": null,
        "userTags": [],
        "name": "smcli-si",
        "description": "smcli-si",
        "tokenExpiresOn": null,
        "tokenExpirationInDays": 0,
        "serviceIdentityType": "Federated",
        "userId": "2optdq8xt8qg8okpy2vt"
    }

    4. List of Service Identities

    This API returns the list of all service identities. The API returns data in pages and multiple API calls have to be made to return the complete list. The API returns the total number of records that can be used to calculate the number of pages.

    GET{{url}}/api/users?type=ServiceIdentity&page=0&size=20&sort=name,asc&filter=status eq active 

    Request Parameters

    The request parameters used in this method are shown in the following table:

    ParameterDescriptionData TypeRequired

    page

    The page number starting from zero.

    string

    Mandatory

    size

    The number of records that are returned. 

    Note: The total number of records can be used to calculate the number of pages. For example, 20.

    string

    Mandatory

    sort

    The column is used for sorting the records.

    string

    Optional

    filter

    The filter that can filter the list of service identities based on name, status, role, and service identity type. The supported operators are 'eq' and 'co'. 
    An example format is given here: name co "Smith"

    string

    Optional

    Request Example

    An example GET request for retrieving the details of service identities is shown here.

    ShellShell
    curl --location --request GET '{{url}}/api/users?type=ServiceIdentity&page=0&size=20&sort=name,asc&filter=status%20eq%20active' \
    --header 'Authorization: TOKEN {{token}}'

    Response Example

    An example response of the GET request for retrieving the details of service identities is shown here. 

    Status: 200 OK
    JSONJSON
    {
      "count" : 2,
      "page" : 0,
      "size" : 20,
      "sort" : null,
      "filter" : "searchText co arpita",
      "data" : [ {
        "status" : "active",
        "adminRoles" : [ ],
        "type" : "ServiceIdentity",
        "created" : "2022-12-19T03:10:26Z",
        "modified" : null,
        "lastLogin" : null,
        "userTags" : [ ],
        "name" : "Arpitatest2",
        "description" : "",
        "tokenExpiresOn" : null,
        "tokenExpirationInDays" : 0,
        "serviceIdentityType" : "Static",
        "userId" : "irnuchk39mwrtb0clx4b"
      }, {
        "status" : "inactive",
        "adminRoles" : [ ],
        "type" : "ServiceIdentity",
        "created" : "2023-02-10T05:27:45Z",
        "modified" : "2024-01-22T06:39:29Z",
        "lastLogin" : null,
        "userTags" : [ ],
        "name" : "arpita-fed",
        "description" : null,
        "tokenExpiresOn" : null,
        "tokenExpirationInDays" : 0,
        "serviceIdentityType" : "Federated",
        "userId" : "2b2xqe4ntxbpku4kl4ii"
      }]
    }



    Was this article helpful?

    What's Next