Highlighted
Frequent Contributor.
Frequent Contributor.
2646 views

rest api authentication: How to send Basic Auth info to server in header in vugen

Jump to solution

Hi 

I have situation where i have to send "Authorization:Basic Auth Usename:SomeName,Password:SomePassword" to authenticate rest api.

In Postman We can send this ,it has Authorization Tab so we can easily select Authorization as Basic Auth and we can give user name and password directly in the fields.But how we can pass this Authorization info Vugen to make succesfull request.

I found some info in internet and tried below things but did not work.

web_set_user("Username","password","domain:port");

web_set_socket_option("INTIAL_BASIC_AUTH","1");

please find image:basic auth.PNG

please help me on this ASAP

thanks in advance

Mahesh

 

 

 

0 Likes
1 Solution

Accepted Solutions
Highlighted
Respected Contributor.
Respected Contributor.

Re: rest api authentication: How to send Basic Auth info to server in header in vugen

Jump to solution

Hi Mahesh,

Looking at the screenshot you shared, Postman would be adding a Header to the request. So you can't use web_set_user() in Vugen script.

Instead, you need to use web_add_header("Authorization","<value>");

Value here has to be UserName:Password in Base64 Encode. Use https://www.base64encode.org/, to convert.

For example, if User ID is 'PerformanceTester' and Password is 'Password123',  the Encoded value is "UGVyZm9ybWFuY2VUZXN0ZXI6UGFzc3dvcmQxMjM="

So, web_add_header("Authorization", "UGVyZm9ybWFuY2VUZXN0ZXI6UGFzc3dvcmQxMjM=");

 

Thanks,

Girish

View solution in original post

0 Likes
3 Replies
Highlighted
Respected Contributor.
Respected Contributor.

Re: rest api authentication: How to send Basic Auth info to server in header in vugen

Jump to solution

Hi Mahesh,

Looking at the screenshot you shared, Postman would be adding a Header to the request. So you can't use web_set_user() in Vugen script.

Instead, you need to use web_add_header("Authorization","<value>");

Value here has to be UserName:Password in Base64 Encode. Use https://www.base64encode.org/, to convert.

For example, if User ID is 'PerformanceTester' and Password is 'Password123',  the Encoded value is "UGVyZm9ybWFuY2VUZXN0ZXI6UGFzc3dvcmQxMjM="

So, web_add_header("Authorization", "UGVyZm9ybWFuY2VUZXN0ZXI6UGFzc3dvcmQxMjM=");

 

Thanks,

Girish

View solution in original post

0 Likes
Highlighted
Frequent Contributor.
Frequent Contributor.

Re: rest api authentication: How to send Basic Auth info to server in header in vugen

Jump to solution

Thanks for your reply Girish.It worked for me.In Postman its gernerate a temporary header from these aunthentication information.I used that insted of www.base64encode.org.

-Mahesh

 

0 Likes
Highlighted
Respected Contributor.
Respected Contributor.

Re: rest api authentication: How to send Basic Auth info to server in header in vugen

Jump to solution

Postman is internally converting your User ID and Password to generate this header.

Thanks,

Girish

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.