Authenticate Method  
 

Authenticate the client session with a username and password.

Syntax

object.Authenticate( UserName, Password, [AuthType] )

Parameters

UserName
A string which specifies the username used to authenticate the client session.
Password
A string which specifies the password which will be used to authenticate the client session with the server. Not all server resources require the client to authenticate the session. If you are using OAuth 2.0 authentication, this parameter specifies the bearer token.
AuthType
An optional value which specifies the authentication method. If this parameter is omitted, it will use the method specified by the AuthType property. It may be one of the following values:
Value Constant Description
0 httpAuthNone No client authentication should be performed.
1 httpAuthBasic The Basic authentication scheme should be used. This option is supported by all servers that support at least version 1.0 of the protocol. The user credentials are not encrypted and Basic authentication should not be used over standard (non-secure) connections. Most web services which use Basic authentication require the connection to be secure.
4 httpAuthBearer The Bearer authentication scheme should be used. This authentication method does not require a user name and the BearerToken property must specify the OAuth 2.0 bearer token issued by the service provider. If the access token has expired, the request will fail with an authorization error. This function will not automatically refresh an expired token.

Return Value

A value of zero is returned if the method was successful. Otherwise, a non-zero error code is returned which indicates the cause of the failure.

Remarks

This method will set the Authorization request header for the client session using the credentials provided by the caller. It will always override any custom Authorization header value which may have been previously set using the SetHeader method.

If both the UserName and Password parameters specify empty strings, the current authentication type will always be set to httpAuthNone regardless of the value of the AuthType parameter. This effectively clears the current user credentials for the client session.

If you provide a user name and password to the Connect method, or you set the UserName property and either the Password or BearerToken property prior to calling the Connect method, authentication will be automatically attempted at the time the connection is made. This method is only required if you do not provide user credentials when the connection is established and wish to authenticate the client session at a later time.

See Also

AuthType Property, BearerToken Property, Password Property, UserName Property, Connect Method SetHeader Method