v3 API Examples Using Curl

<Tokens>

1,Default scope 获取token

Get an token with default scope (may be unscoped):

Tips CLI如下:

curl -i \

  -H "Content-Type: application/json" \

  -d '

{ "auth": {

    "identity": {

      "methods": ["password"],

      "password": {

        "user": {

          "name": "demo",

          "domain": { "id": "default" },

          "password": "321"

        }

      }

    }

  }

}' \

  http://5.10.124.181:5000/v3/auth/tokens ; echo

OpenStack IdentityService Keystone V3 API Curl实战_ide

2,Project-scoped

Get a project-scoped token:

curl -i \

  -H "Content-Type: application/json" \

  -d '

{ "auth": {

    "identity": {

      "methods": ["password"],

      "password": {

        "user": {

          "name": "demo",

          "domain": { "id": "default" },

          "password": "321"

        }

      }

    },

    "scope": {

      "project": {

        "name": "demo_project",

        "domain": { "id": "default" }

      }

    }

  }

}' \

  http://5.10.124.181:5000/v3/auth/tokens ; echo

OpenStack IdentityService Keystone V3 API Curl实战_ide_02

3,Domain-Scoped

Get a domain-scoped token (Note that you’re going to need a role-assignment on the domain first!):

curl -i \

  -H "Content-Type: application/json" \

  -d '

{ "auth": {

    "identity": {

      "methods": ["password"],

      "password": {

        "user": {

          "name": "admin",

          "domain": { "id": "default" },

          "password": "321"

        }

      }

    },

    "scope": {

      "domain": {

        "id": "default"

      }

    }

  }

}' \

  http://5.10.124.181:5000/v3/auth/tokens ; echo

OpenStack IdentityService Keystone V3 API Curl实战_ide_03

4,Getting a token from a token

OpenStack IdentityService Keystone V3 API Curl实战_json_04

5,DELETE /v3/auth/tokens

Revoke a token:

OpenStack IdentityService Keystone V3 API Curl实战_ide_05

<二,Domains>

Get /v3/domains

List domains: