Help Center> Identity and Access Management> FAQ> Others> How Do I Obtain a User Token Using Postman?

How Do I Obtain a User Token Using Postman?

Postman is a visual editing tool for building and testing API requests. It provides an easy-to-use user interface to send HTTP requests, including GET, PUT, POST, and DELETE requests. Postman allows you to modify parameters of HTTP requests and returns response to your requests.

A token is a user's access credential, which includes user identities and permissions. When you call an API to access cloud resources, a token is required for identity authentication.

Perform the procedure described in this section to obtain a user token using Postman. For details about the parameters, see Obtaining a User Token.

Prerequisites

You have installed and registered with Postman.

Procedure

  1. Edit the request URL, header, and body of the API used to obtain a token for calling APIs.

    • Request URL
      The request URL is in the format "https://IAM region and endpoint/API URI".
      1. Obtain the IAM region and endpoint from Regions and Endpoints.
        Figure 1 IAM regions and endpoints

          

      2. Obtain the API URI from Obtaining a User Token.

        For example, the request URL in the cn-north-1 region is https://iam.cn-north-1.myhuaweicloud.com/v3/auth/tokens.

      3. Select an API request method and enter the request URL in Postman.
        Figure 2 Example request URL

          

    • Request Header

      Set key to Content-Type and value to application/json;charset=utf8.

      Figure 3 Example header

        

    • Request Body
      Modify parameters in the example request body.
      {
      	"auth": {
      		"identity": {
      			"methods": [
                                      "password"
                               ],
      			"password": {
      				"user": {
      					"domain": {
      						"name": "Account name"
      					},
      					"name": "IAM user name",
      					"password": "IAM user password"
      				}
      			}
      		},
      		"scope": {
      			"domain": {
      				"name": "Account name"
      			}
      		}
      	}
        }
      • For details about how to obtain the account name and IAM user name, see Obtaining Account, IAM User, and Project Information.
      • If your HUAWEI CLOUD account has been upgraded to a HUAWEI ID, you cannot obtain a token using the HUAWEI ID. However, you can create an IAM user, grant the user required permissions, and obtain a token as the user.
      • If you are a user of a third-party system, you cannot obtain a token by using the username and password that you use for federated identity authentication. Go to the HUAWEI CLOUD login page, click Forgot password, click Reset HUAWEI CLOUD account password, and set a new password.

  2. Click Send to send the API request.

    Figure 4 Sending an API request

      

  3. View the token in the response header. You can use this token for authentication when you call other IAM APIs.

    Figure 5 Obtained token

Why Am I Seeing a Message Indicating Header Overflow When I Attempt to Use Postman to Obtain a Token?

Postman of V7.25.0, V7.26.0, or a later version cannot be used to obtain a user token due to configurations. The message "Header Overflow" will be displayed if you use any of these versions.

  • Solution 1

    Use an earlier version of Postman, such as V 5.xx.

  • Solution 2:

    Use curl to obtain a token and replace the text in bold with actual values:

    curl -ik -X POST -H 'Content-Type=application/json;charset=utf8' -d '{"auth": {"identity": {"methods": ["password"],"password": {"user": {"domain": {"name": "Account name"},"name": "IAM user name","password": "IAM user password"}},},"scope": {"domain": {"name": "Account name"}}}}' https://iam.cn-north-1.myhuaweicloud.com/v3/auth/tokens
  • Solution 3

    Pass an additional environment variable NODE_OPTIONS=--max-http-header-size=16384 (16KB) to Postman to specify the maximum size of the HTTP header (in bytes).

    Run one of the following commands depending on your OS:

    • macOS
      NODE_OPTIONS=--max-http-header-size=16384 /Applications/Postman.app/Contents/MacOS/Postman 
    • Linux
      NODE_OPTIONS=--max-http-header-size=16384 /path/to/Postman/Postman 
    • Windows
      set NODE_OPTIONS=--max-http-header-size=16384 
      C:\users\<username>\AppData\local\Postman\Postman.exe