VMware Networking Community
nodsalot
Contributor
Contributor

Authorization using AUTHTOKEN failing (but basicauth succeeds)

I do successfully receive a token when POSTing to  `/services/auth/token`, but when I then turn around and send a GET to `/api/2.0/services/auth/tokenexpiration` with the token in the header I get a 500.  My user can navigate thru the NSX section of vSphere, and change settings.  I have tried this using curl, python, and postman.

details:

the POST request:

```

/usr/bin/curl -H 'Accept: application/json' -H 'Content-Type: application/json' -H 'Authorization: Basic XXXXXXXXXXXXXX' -X POST 'https://vSphere-server.example.com//api/2.0/services/auth/token'

```

the associated response contains the token in the format `xxxxx.yyyyyy.zzzzzz`.  I use that to perform the following GET.

the GET request:

```

/usr/bin/curl -H 'Accept: application/json' -H 'Content-Type: application/json' --header 'Authorization: AUTHTOKEN xxxxx.yyyyy.zzzzzz' https://vSphere-server.example.com/api/2.0/services/auth/tokenexpiration

```

this is when i get the 500.

- If I alter the token, then I get a 403, as expected.

- If i use basic-auth instead of token-auth for the GET, I get a json object with a `expiresIn` element, as desired.

So, something seems broken with the token auth.

However, I do not wish to store user credentials in my script. So, I really need token-auth to work.

oh, I am connecting to vSphere Version 6.5.0 (old version is out of my control.)  curl and postman are up-to-date.

thanks.

P.S. if i have left out anything (other than credentials), let me know.  I will update it.

Tags (3)
Reply
0 Kudos
0 Replies