VMware Cloud Community
slahy
Enthusiast
Enthusiast
Jump to solution

HTTP-REST Plugin Basic Authentication Help

I am trying to perform a REST login with a host in the inventory of the VCO plugin. The login request returns an authorisation token in the response header which is then set as a header in all subsequent REST calls in VCO. I am able to perform the login and get an authorisation token in the response header in browser based REST clients. However if I do the same REST login call in VCO it appears to strip out the response header as response.getHesders() for the login call returns null.

It seems that the authorisation in the HTTP-REST plugin is handled differently, I would like to know how to perform a login with the HTTP-REST plugin. The REST API that I am attempting to interface with has a login operation as follows.

GET /login

Request

GET https://192.168.1.10:4534/login

Headers

Content-Type: application/xml

Authorization: Basic base64EncodedString comprising of 'username:password'

Response

Headers

X-SDS-AUTH-TOKEN: <AUTH_TOKEN>

Body

HTTP/1.1 200 OK

Content-Type: application/xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<loggedIn>

  <user>username</user>

</loggedIn>

How do I access this auth token in VCO ? Is it accassable via the REST-Host ?

I have also attempted to configure the host in the HTTP-REST plugin with basic authentication and a session mode of ‘Per User Session’ but I am unsure how to pass the username and password to the host when using this session mode.

Thanks

slahy

Reply
0 Kudos
1 Solution

Accepted Solutions
slahy
Enthusiast
Enthusiast
Jump to solution

I found an example of accessing headers in the link below and it seems that you need to place the response into a variable to access the content of the response. Seems a little strange to me but it works.

var SessionResponse = new Properties();

SessionResponse.put("statusCode", CreateSession.statusCode);

SessionResponse.put("headers", CreateSession.getAllHeaders());

if ( SessionResponse.statusCode == "200") {

     System.log("Session successful created")

xZertoSessionKey = SessionResponse.headers.get("x-zerto-session")

}

else {

     System.log("Session could not be established")

}

http://www.vcoportal.de/2014/06/automate-your-zerto-disaster-recovery-solution-with-vco/

View solution in original post

Reply
0 Kudos
2 Replies
tschoergez
Leadership
Leadership
Jump to solution

For your last question: If you use the REST Plugin in "per-user session" then automatically the username/password of the vCO user that is starting the workflow is passed to the REST Host.

Does it work if you use a "shared session" basic authentication for the REST host?

Reply
0 Kudos
slahy
Enthusiast
Enthusiast
Jump to solution

I found an example of accessing headers in the link below and it seems that you need to place the response into a variable to access the content of the response. Seems a little strange to me but it works.

var SessionResponse = new Properties();

SessionResponse.put("statusCode", CreateSession.statusCode);

SessionResponse.put("headers", CreateSession.getAllHeaders());

if ( SessionResponse.statusCode == "200") {

     System.log("Session successful created")

xZertoSessionKey = SessionResponse.headers.get("x-zerto-session")

}

else {

     System.log("Session could not be established")

}

http://www.vcoportal.de/2014/06/automate-your-zerto-disaster-recovery-solution-with-vco/

Reply
0 Kudos