Method HttpClient():setAuthorization() Foundation

Sets username and password for server authentication.

Syntax
 
:setAuthorization( [<cUsername>, <cPassword>] ) --> self
Parameters
<cUserName>
A character string with the name of the user to be authenticated. This parameter is optional. If no user name is specified, the user name and password set in a previous call to :setAuthorization() are removed.
<cPassword>
A character string with the user's password. This parameter may be omitted if no user name is passed in <cUsername>. Otherwise, <cPassword> is mandatory.
Return

:setAuthorization() returns the object executing the method.

Description

The method :setAuthorization() specifies the credentials for the user to be authenticated on the server for performing subsequent requests. These credentials can later be reset by calling :setAuthorization() without parameters. Afterwards, no user will be authenticated when performing requests.

The method :setAuthorization() automatically enforces negotiation with the server regarding the authentication scheme to be used. Suppported schemes are listed below.

Authentication schemes supported by :setAuthorization()
Scheme Description
Basic User name and password are sent to the server as a Base64-encoded string
NTLM NT LAN Manager Authentication
Digest Digest Access Authentication
Negotiate *) Uses NTLM or Kerberos authentication depending on client and server OS
  1. Kerberos is used when both client and server use Windows 2000 or later'

In case the Basic authentication scheme is used, the credentials specified in the parameters to :setAuthorization() are stored in the "Authorization" header element of the HTTP request object assigned to the :httpRequestmember variable. This HTTP request object is used as the default for requests sent using the methods :send() and :sendAsync().

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.