Is there a way to check the life of a token?

467 Views Asked by At

I need to check if the token is valid every time I run the script. In case it is valid, but skip the procedure for generating a new token. Is it possible to implement this by means of api?

I receive a token through curl

export SYS_TOKEN=curl --silent -i --cacert "$OS_CACERT" \
        -X POST $OS_AUTH_URL/v3/auth/tokens -d '{"auth":{"identity":\
        {"methods":["password"],"password":{"user":{"name": "'$USERNAME'", "domain":\
        {"name": "default"}, "password": "'$PASSWORD'"}}}}}' \
        -H 'Content-type: application/json' | \
        awk -F ':' '/^X-Subject-Token/ {print $2}' | sed -e 's/\r$//'
1

There are 1 best solutions below

1
berndbausch On

Keystone implements the Check Token API.

I do wonder what is the use case. Whenever you submit an API, the token's validity is checked anyway. What do you gain by checking validity yourself?