VMware Cloud Community
dmgeurts
Enthusiast
Enthusiast
Jump to solution

REST API authentication [RESOLVED]

Found plenty of detail about using REST API, but not how to troubleshoot a failing login. I've verified the credentials and UI login works fine with these credentials so I'm confused why it's not working:

AUTH64=$(printf 'user@domain.com:************' | base64)
curl -k -X POST https://vcenter.some.domain.com/api/session -H "Authorization: Basic ${AUTH64}"

{"error_type":"UNAUTHENTICATED","messages":[{"args":[],"default_message":"Authentication required.","id":"com.vmware.vapi.endpoint.method.authentication.required"}]}

So far I've tried 'username', 'domain/username' and 'username@domain'. I'm using FreeIPA as LDAP backend and using the local admin user doesn't work either. What on earth am I doing wrong?!

Silly error in the end that took way too much time: echo includes a line feed which base64 happily includes in the parsed string. Using printf is a better option here (one could also use echo with a flag to inhibit the line feed). The example above was amended with printf.

1 Solution

Accepted Solutions
dmgeurts
Enthusiast
Enthusiast
Jump to solution

For clarity, I'm trying to use the new API (/api/session) rather than the old one (/vmware/cis/session).

Edited the original post. I got caught out by a simple line feed...

View solution in original post

Reply
0 Kudos
1 Reply
dmgeurts
Enthusiast
Enthusiast
Jump to solution

For clarity, I'm trying to use the new API (/api/session) rather than the old one (/vmware/cis/session).

Edited the original post. I got caught out by a simple line feed...

Reply
0 Kudos