VMware Cloud Community
ccurry
Contributor
Contributor

Unable to authenticate via API on vCloud Director

I am having issues authenticating with the vCloud Director API. I am using the following cURL commands:

curl -i -k -H "Accept:application/*+xml;version=1.5" -u '[username]@[LDAP Domain]:[password]' -X POST https://[vCloud Director IP]/api/sessions


curl --request POST --url https://[vCloud Director IP]/api/sessions --header 'accept: application/*+xml;version=5.6' --header 'authorization: Basic [encodedCredentials]


and I get a '401 Unauthorized' return code. I am trying to connect to vCloud Director v8.10.0.3879706. The account I am trying to use in the cURL command is the same one I connect to the Web Portal as, which has System Administrator privileges. I have also tried connecting as an Organisation Administrator user in a specific VDC. I am able to get output from /api/versions, so I know the API is functioning.


Can anyone help locate the cause of this 401 return code issue? It seems to me it's a problem with how I'm formatting my credentials, but I can't find the exact issue. The credentials look something like this:


exampleuser@this.ldap.domain:Test$Pass%


Thanks.

Reply
0 Kudos
5 Replies
dmcdave212
Enthusiast
Enthusiast

Hello

Are you logging into the API as an Administrator or as a tenant?  If you are an administrator, try using [username]@SYSTEM:[password].  I don't need to specify the LDAP domain on mine, so I just use d_lee@SYSTEM for my login.

If you are logging in as a tenant, then put your Organisation Name instead of system.  So in my vCD instance, our Org names are based on a customer account ID so if a customer has ID of 12345 then he would log in using username@12345.

Dave

Reply
0 Kudos
spoon77
Contributor
Contributor

Although this is almost a year later.

I had similar issue, which was casued by the base64 encryption on my Ubuntu.

Since you are using curl I assume that you are encrypting your login using linux as well.

Try one of the tools online, I found this one working for me: Base64 Encode - Online Tool

Ubuntu's base64 was short of '=' character at the end of the encryption.

Reply
0 Kudos
raghav3
Contributor
Contributor

Facing same issue with VCD 10.2. Cant login using administrator@system. Any ideas??

Reply
0 Kudos
DjinjiRinji
Enthusiast
Enthusiast

What tool is being used? Can you post the call code here to see? (remove sensitive data)

Kindly mark as solved if your questions are answered.
>>>>>
Guillermo R
LinkedIn: https://www.linkedin.com/in/gramallo
Web: http://bakingclouds.com/
Reply
0 Kudos
raghav3
Contributor
Contributor

Hi,

 

It was resolved by enabling legacy API /api/sessions endpoint for provider on vCloud Director

 

/opt/vmware/vcloud-director/bin/cell-management-tool manage-config -n vcloud.api.legacy.nonprovideronly -v false
Reply
0 Kudos