0

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$//'
Walter A
  • 19,067
  • 2
  • 23
  • 43
Kaber
  • 35
  • 5

1 Answers1

0

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?

berndbausch
  • 869
  • 10
  • 18
  • I have a script that asks for a new token every time it starts. I would like to make a validation check so that there are no such frequent requests. – Kaber Jul 13 '21 at 08:02