While verifying Openstack RESTful API, I generated a token with default scope using the cURL command as shown below and exported the token to the OS_TOKEN
environment variable as explained in this link.
curl -i \ -H "Content-Type: application/json" \ -d ' { "auth": { "identity": { "methods": ["password"], "password": { "user": { "name": "admin", "domain": { "id": "default" }, "password": "adminpwd" } } } } }' \ "http://tg.com:5000/v3/auth/tokens" ; echo
By doing that, the token can be used in all successive API queries by using the variable at necessary places. However, I ended with an error unexpected keyword argument 'token'
error while executing OpenStack commands. The complete error message is below:
__init__() got an unexpected keyword argument 'token'
How to solve __init__() got an unexpected keyword argument ‘token’
Step1: List all the Openstack environment variables set starting with string ‘OS’.
# env | grep ^OS OS_USER_DOMAIN_NAME=default OS_IMAGE_API_VERSION=2 OS_PROJECT_NAME=admin OS_IDENTITY_API_VERSION=3 OS_PASSWORD=password OS_AUTH_URL=http://tg.com:5000/v3 OS_TOKEN=gAAAAABhtwVXmV_JHkId2s.....CNnGazfpKdtSSgKlGTuU OS_USERNAME=admin OS_VOLUME_API_VERSION=3 OS_PROJECT_DOMAIN_NAME=default
Step 2: The issue was with the environment variable OS_TOKEN
that I had set. It seems the environment should be set and used with any of the cURL commands. For example, we can use the below cURL command to access the compute API to list all the flavors along with the OS_TOKEN variable.
$ curl -s -H "X-Auth-Token: $OS_TOKEN" \ $OS_COMPUTE_API/flavors \ | python -m json.tool
The above command would work fine, but the same variable can’t be used along with the OpenStack commands as discussed in this link.
# unset OS_TOKEN
Step 3: Now all the Openstack commands in the command line works. If you want to store the token to an environment variable, then you can use some other variable name other than OS_TOKEN.
Follow here for other Openstack issues.