• Native OpenStack API

noa
  1. Help Center
  2. Native OpenStack API
  3. API Reference
  4. Keystone
  5. Credential Management
  6. Obtaining a Temporary AK/SK

Obtaining a Temporary AK/SK

Function Description

This interface is used to obtain a temporary access key (AK/SK) and security token (offline AK/SK) by using the assume_role method, a common token, or a federated token.

A temporary AK/SK is a token with temporary permissions issued to users. It conforms to the principle of least privilege and can be used to temporarily access OBS.

URI

URI format

POST /v3.0/OS-CREDENTIAL/securitytokens

Request

  • Request header parameter description
    • When the methods parameter is set to assume_role

      Parameter

      Mandatory

      Type

      Description

      X-Auth-Token

      Yes

      String

      Authenticated token with the Agent Operator permission.

      Content-Type

      Yes

      String

      Fill application/json;charset=utf8 in this field.

    • When the methods parameter is set to token

      Parameter

      Mandatory

      Type

      Description

      Content-Type

      Yes

      String

      Fill application/json;charset=utf8 in this field.

      X-Auth-Token

      No

      String

      Common token or federated token required for obtaining a temporary AK/SK. You need to choose either this parameter value or the ID in the token object in the request body. X-Auth-Token takes priority over the ID in the token object.

  • Request body parameter description
    • When the methods parameter is set to assume_role

      Parameter

      Mandatory

      Type

      Description

      methods

      Yes

      String Array

      Fill assume_role in this field.

      agency_name

      Yes

      String

      Agency name.

      domain_name or domain_id

      Yes

      String

      If methods is set to assume_role, choose either domain_name or domain_id.

      duration-seconds

      No

      Int

      Validity period (in seconds) of an AK/SK and security token. The value ranges from 15 minutes to 24 hours. The default value is 15 minutes.

      scope

      No

      Object

      Range in which the AK/SK takes effect. If this parameter is left blank, the generated security token does not contain the scope information. You are advised to leave this parameter blank. If this parameter is set, id under this parameter can be a project ID, domain ID, or domain name.

      For example:

      "scope": {
            "project": {
            "id": "0215ef11e49d4743be23dd97a1561e91"
            }
          }

      id indicates a project ID.

      scope": {
            "domain": {
            "id": "0234ef11e49d4743be23dd97a1561e91"
            }
          }

      id indicates a domain ID.

      scope": {
            "domain": {
            "name": "testname"
            }
          }

      name indicates a domain name.

    • When the methods parameter is set to token

      Parameter

      Mandatory

      Type

      Description

      methods

      Yes

      String Array

      Fill token in this field.

      token

      No

      JSON Object

      Common token or federated token required for obtaining a temporary AK/SK. You need to choose either the ID in this object or X-Auth-Token in the request header. X-Auth-Token takes priority over the ID in this object.

      duration-seconds

      No

      Int

      Validity period (in seconds) of an AK/SK and security token. The value ranges from 15 minutes to 24 hours. The default value is 15 minutes.

  • Sample request
    • When the methods parameter is set to assume_role
      {
          "auth": {
              "identity": {
                  "methods": [
                      "assume_role"
                  ],
                  "assume_role": {
                      "domain_id": "411edb4b634144f587ffc88f9bbd1ac8",
                      "xrole_name": "exampleagency",
                      "duration-seconds": "3600"
                  }
              }
          }
      }
    • When the methods parameter is set to token
      {
          "auth": {
              "identity": {
                  "methods": [
                      "token"
                  ],
                  "token": {
                      "id": "MIIDkgYJKoZIhvcNAQcCoIIDgzCCA38CAQExDTALBglghkgBZQMEAgEwgXXXXX...",
                      "duration-seconds": "900"
                  }
              }
          }
      }

Response

  • Response body parameter description

    Parameter

    Mandatory

    Type

    Description

    credential

    Yes

    Object

    Authentication information.

  • Description about the credential content.

    Parameter

    Mandatory

    Type

    Description

    expires_at

    Yes

    String

    Expiration time.

    access

    Yes

    String

    AK

    secret

    Yes

    String

    SK

    securitytoken

    Yes

    String

    Used for subsequent replacement of an SK or token.

  • Sample response
    {
      "credential": {
        "access": "NQC51NFINJS1JXX...",
        "secret": "EY74MByPZ46kTRJL9ay5DskqXX...",
        "expires_at": "2017-04-17T07:55:18.575000Z",
        "securitytoken": "gAAAAABY9GbWUaGtoa9DPj7_dE4qUSnAXXX..."
      }
    }

Status Codes

Status Code

Description

201

The request is successful.

400

The server failed to process the request.

401

You must enter a username and password to access the requested page.

403

You are forbidden to access the requested page.

500

Failed to complete the request because of an internal service error.