Quantcast
Channel: VMware Communities : Discussion List - All Communities
Viewing all articles
Browse latest Browse all 178776

vRO REST authentication with vRA Bearer Token fails

$
0
0

Hey community,

 

I have a problem in my environment authenticating against the vRO REST API with a Bearer-Token which was request from vRA.

 

Since last week we have a standalone vRO configured with authentication source "vRealize Automation".

Test Connection in the controlcenter always suceed and login into the vRO Client succeeds aswell.

 

I wrote a PowerShell script which gets a bearer token from vRA by this code:

 

$body = '{"username" : "ThatsMyUser", "password" : "ThatsMySecretPassword", "tenant" : "vsphere.local"}'

$response = Invoke-Webrequest -Uri https://vRA-Loadbalancer.com/identity/api/tokens -Method POST -Headers @{"accept"="application/json"} -Body $body -ContentType "application/json"

$content = response | ConvertFrom-Json

$id = $content.id

 

It returns a ID and if we validate it the vRA Rest API returns that it´s valid (mentioned here: https://docs.vmware.com/en/vRealize-Automation/7.3/com.vmware.vra.programming.doc/GUID-45E4204A-4E9C-4DD4-B7F6-FE6734BD9F9E.html )

So authentication against the vRO REST should work... I guess

 

Now I tried to simply list all packages in vRO by this code:

 

$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"

$headers.Add("Authorization", "Bearer " + $id)  # $id is the same as returned by the upper code

$headers.Add("accept","application/json")

Invoke-Webrequest -Uri https://vRO-Appliance.com:8281/vco/api/packages -Method GET -Headers $headers

 

And it returns and error "401 Unauthorized" ... And I have no clue why.

I tried the same in different languages... vRO itself, C# and PowerShell.

Anyone have a suggestion? ´This made me kinda crazy over the last few days.

 

additional note: I hope there are no typos in the PowerShell code... copy paste didn´t work argh... yes each url is typed by myself


Viewing all articles
Browse latest Browse all 178776

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>