简体   繁体   中英

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

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$//'

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM