INT Authenticate( |
|
UINT nAuthType, |
|
|
LPCTSTR lpszUserName, |
|
|
LPCTSTR lpszPassword |
|
); |
INT Authenticate( |
|
LPCTSTR lpszUserName, |
|
|
LPCTSTR lpszPassword |
|
); |
Parameters
- nAuthType
- An unsigned integer value which specifies the method to be used
when authenticating the client. If this argument is not specified,
then basic authentication will be used. The following values are
recognized.
Value |
Description |
HTTP_AUTH_NONE |
No client authentication should
be performed. The lpszUserName and lpszPassword
parameters are ignored
and current authentication settings are cleared. |
HTTP_AUTH_BASIC |
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. |
HTTP_AUTH_BEARER |
The Bearer authentication
scheme should be used. This authentication method does not require
a user name and the lpszPassword parameter 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. |
- lpszUserName
- A pointer to a string that specifies the
username used to authenticate the client session. This parameter may
be NULL or an empty string if a user name is not required for the
specified authentication type.
- lpszPassword
- A pointer to a string that specifies the
password used to authenticate the client session.
Return Value
If the method succeeds, the return value is zero. If the method
fails, the return value is HTTP_ERROR. To get extended error
information, call GetLastError.
Remarks
This method will set the Authorization request header
for the client session using the credentials provided by the caller.
This method will always override any custom Authorization
header value that may have been previously set using the
SetRequestHeader method.
If both the lpszUserName and lpszPassword
parameters are NULL pointers or specify zero length strings, the
current authentication type will always be set to HTTP_AUTH_NONE
regardless of the value of the nAuthType parameter. This
effectively clears the current user credentials for the client session.
If the web service requires OAuth 2.0 authentication, it is
recommended you use the SetBearerToken method
to specify the access token.
Requirements
Minimum Desktop Platform: Windows 7 (Service Pack 1)
Minimum Server Platform: Windows Server 2008 R2 (Service Pack 1)
Header File: cstools11.h
Import Library: cshtpv11.lib
Unicode: Implemented as Unicode and ANSI versions
See Also
Connect,
GetBearerToken,
SetBearerToken,
SetHeader
|