How to authenticate the client in a HTTP request using "Basic" authorization

I Love Xbase++ (ILX)
The portal for Xbase++ developers worldwide

Till Warweg

Member
Staff member
I am here to help you!
Feb 1, 2021
36
7
8
Customer Identifier
E074775
In order to authenticate the client in an HTTP request, the client's credentials must be specified in the request. To do this, the method :setAuthorization() of the HttpClient class can be used. This method automatically sets an "Authorization" HTTP header in the required format. If the server requires "Basic" authorization, :setAuthorization() automatically constructs an HTTP header of the following form:

Xbase++:
Header: "Authorization"
Value : "Basic <credentials>" // "<credentials>" is a Base64-encoded string with the client's credentials specified as "<user>:<password>".

Example:
Xbase++:
oClient := HttpClient():new( "http://httpbin.org/basic-auth/a/b" )
oClient:setAuthorization( "a", "b" )
 
Last edited by a moderator: