Search code examples
openstack

The token is not the host machine's system time


In the host machine I use :

curl -k -X 'POST' -v http://10.1.1.186:5000/v2.0/tokens -d '{"auth":{"passwordCredentials":{"username": "guol", "password":"123456"}}}' -H 'Content-type: application/json' | python -mjson.tool

to generate the token:

...
* Closing connection 0
{
    "access": {
        "metadata": {
            "is_admin": 0,
            "roles": []
        },
        "serviceCatalog": [],
        "token": {
            "audit_ids": [
                "HqVGww9JT2G2wSKzd9v3uA"
            ],
            "expires": "2017-08-16T13:16:14Z",
            "id": "gAAAAABZlDeOO4s1MCfXFP_b9CTl_Znndpt6piBxLRiMTR2TpMp3EfA49chql2a1nfowQST-pQCqaBe53KBuRNx4moj3RYCIiS24xDALDhqpeYBSkfnVM1EP6dTSKOtEGuQGBNGe5v4RIlzu0ZXKYrmoWPgA7ZFRiw",
            "issued_at": "2017-08-16T12:16:14.000000Z"
        },
        "user": {
            "id": "2a5fa182fb1b459980db09cd1572850e",
            "name": "admin",
            "roles": [],
            "roles_links": [],
            "username": "admin"
        }
    }
}

I get the token success, but however my host machine's time is:2017/8/16 20:18, but the token time is below:

"issued_at": "2017-08-16T12:16:14.000000Z"
"expires": "2017-08-16T13:16:14Z"

EDIT

The host machine timezone is Asia/Shanghai.


Solution

  • The timestamp returned in the JSON file is represented as UTC. You can tell this because it uses the Z suffix.

    As per ISO 8601:

    UTC

    If the time is in UTC, add a Z directly after the time without a space. Z is the zone designator for the zero UTC offset. "09:30 UTC" is therefore represented as "09:30Z" or "0930Z". "14:45:15 UTC" would be "14:45:15Z" or "144515Z".