authenticate
Description
Specify an HTTP authentication scheme and its information before working with web services. The user must be authenticated to the services.
Arguments
scheme
HTTP authentication scheme
Possible values:
- basic: Basic HTTP authentication.
- oauth 2: OAuth 2.0
- digest: Digest authentication.
value
HTTP authentication information (see Notes)
Valid contexts
This action may be used within the following project items: test modules and user-defined actions.
Notes
- You are required to declare this built-in action before the authentication is started. Additionally, this built-in action can also be declared after or before the declaration of create http request.
- value argument: Depends on which authentication scheme is selected, there are different ways to provide HTTP authentication information.
For Basic HTTP authentication scheme: Specify username and password to authenticate with the service you are using. Follow this format
userid:password
.ヒント:You can either input a plain text string or a base64url encoded string. To encode a text string into a base64url encoded string, you can use the Online Base64URL encoder tool.For example: username is John and password is Doe.
- Plain text string:
John:Doe
- Base64url encoded string:
Sm9objpEb2U
- Plain text string:
For OAuth 2.0 scheme: Specifying an access token which is required to access OAuth protected resources. For example:
ya29.Ci-fA76X0cjJXa2Lx0RM-fRyAQ6-6pboEX-iuT7PR-yYV6D-Rfbos7bs151wiL-O7w
For Digest authentication scheme: Specify two fields including username and password to authenticate with the service you are using. Follow this format username:password.
- This action supports the <ignore> modifier. If the string
<ignore>
is present as the value of any of the arguments, or any argument contains an expression that evaluates to<ignore>
, the action is skipped during execution.
Applicable Built-In Settings
The following settings are applicable to this action: remove double quotes from cells.
Example 1 - Basic authentication scheme
Suppose that you’d like to test the a given API based on the following information:
- Authentication scheme: Basic authentication
- Web service under test:
http://192.168.190.212:8091/api/authenticate``
- Username: john.doe
- Password: R6z,nUjeH];3L4r:
Action Lines
Example 2 - OAuth 2.0 authentication scheme
Suppose that you’d like to test a given Gmail API to get all messages based on the following information:
Authentication scheme: OAuth 2.0
Web service under test: Users.messages: get
Access token:
ya29.Ci-fA76X0cjJXa2Lx0RM-fRyAQ6-6pboEX-iuT7PR-yYV6D
ヒント:For Google APIs in order to retrieve the access token for OAuth 2.0, read here.
Action Lines
Example 3 - Digest authentication scheme
Suppose that you’d like to test a given API based on the following information:
- Authentication scheme: Digest authentication
- Web service under test:
http://192.168.190.212:8091/api/authenticate``
- Username: john.doe
- Password: 123
Action Lines
Related concepts