proposalbot d748eab4d5 Changes to dds_api-ref from docs/doc-exports#410 (DDS API 20221101 version
DDS

Reviewed-by: Boka, Ladislav <ladislav.boka@t-systems.com>
Co-authored-by: proposalbot <proposalbot@otc-service.com>
Co-committed-by: proposalbot <proposalbot@otc-service.com>
2022-11-09 23:26:45 +00:00

3.3 KiB

original_name

dds_api_0010.html

Token Authentication

Application Scenarios

If you use a token for authentication, you must obtain the user's token and add X-Auth-Token to the request message header of the service API when making an API call.

This section describes how to make an API call for token authentication.

Invoking an API

  1. Obtain the following information:

    1. To obtain the IAM endpoint and region name in the message body, see Regions and Endpoints.
    2. To obtain the project ID, see Obtaining a Project ID <dds_projectid>.
  2. Send a POST https://*IAM\_Endpoint*/v3/auth/tokens request to obtain the user token.

    Table 1 Header description
    Name Description Mandatory Example
    Content-Type Specifies the MIME type of the request body. Yes application/json

    An example request message is as follows:

    {
        "auth": {
            "identity": {
                "methods": [
                    "password"
                ],
                "password": {
                    "user": {
                        "name": "username",
                        "password": "password",
                        "domain": {
                            "name": "domainname"
                        }
                    }
                }
            },
            "scope": {
                "project": {
                   "id": "project_id"
                 }
            }
        }
    }

    In the preceding command, replace parameter in italic with the actual values. For details, see the "Obtaining a User Token" section in the Identity and Access Management API Reference.

    1. IAM_Endpoint: Replace it with the IAM endpoint obtained in 1 <dds_api_0010__en-us_topic_0110967262_li14280177102918>.
    2. username and password: Replace them respectively with the username and password of the IAM server.
    3. project_id: Replace it with the project ID obtained in 1 <dds_api_0010__en-us_topic_0110967262_li14280177102918>.

    After the request is processed, the value of X-Subject-Token in the header is the token value.

    X-Subject-Token:MIIDkgYJKoZIhvcNAQcCoIIDgzCCA38CAQExDTALBglghkgBZQMEAgEwgXXXXX...
  3. Run the following command to set the token as an environment variable for subsequent operations:

    export Token={X-Subject-Token}

    X-Subject-Token: Replace it with the token obtained in 2 <dds_api_0010__en-us_topic_0110967262_li109381224173013>. An example command is as follows:

    export Token=MIIDkgYJKoZIhvcNAQcCoIIDgzCCA38CAQExDTALBglghkgBZQMEAgEwgXXXXX...