Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Navigation
Guide That Contains This Content
[+] Expand All
[-] Collapse All

    Obtaining a Token to Work With the APIs

    You must obtain an authentication token to work with the Cloud CPE Centralized Deployment Model APIs. When you have obtained the token, you can store it and use it for all future API operations.

    This procedure uses the following Identity and Access Manager API:
    http://server-IP-address:5000/v3/auth/tokens

    Table 1 shows the fields that you must specify for this procedure.

    Table 1: Required Fields for Obtaining a Token to Work with APIs

    Field

    Description

    Example

    auth: scope: project: domain: id

    Domain for authorization of the project

    default

    auth: scope: project: name

    Project name—admin (fixed text string)

    admin

    Identity: password: user: domain: id

    Domain for identity

    default

    identity: password: user: name

    Username—admin (fixed text string)

    admin

    Identity: password: user: password

    Password for accessing the API server

    contrail123

    To obtain a token:

    1. Create an input file.
      For example:
      ubuntu@vm1:~$ cat auth.json
      { 
        "auth": { 
          "scope": { 
            "project": { 
              "domain": { 
                "id": "default" 
              },  
              "name": "admin" 
            } 
          }, 
          "identity": { 
            "password": { 
              "user": { 
                "domain": { 
                  "id": "default" 
                },  
                "password": "contrail123",  
                "name": "admin" 
              } 
            },  
            "methods": [ 
              "password" 
            ] 
          } 
        } 
      } 
    2. Issue a REST call to get a token.

      The API returns a token in a header with the tag X-Subject-Token.
      For example:

      ubuntu@vm1:~$ curl -X POST -D headers -H "content-type:application/json" http://10.102.56.40:5000/
      v3/auth/tokens -d@auth.json
    3. Display the token.
      For example:
      ubuntu@vm1:~$ cat headers | grep X-Subject-Token
       
      X-Subject-Token: 5ae68fb453de4f638a79605f70061468
    4. Store the token in an environment variable so that you can use it for subsequent API operations.
      For example:
      ubuntu@vm1:~$ export OS_TOKEN=5ae68fb453de4f638a79605f70061468
      ubuntu@vm1:~$ echo $OS_TOKEN
      5ae68fb453de4f638a79605f70061468

    Modified: 2016-01-29