authenticate

Specify an HTTP authentication scheme and its information before working with web services.
NameDescriptionTypeModifier
schema

HTTP authentication scheme

Possible values:

Value SetBasic, OAuth 2, Digest
value

HTTP authentication information (see ).

StringNone
None
This action may be used within the following project items: test modules and user-defined actions.
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:
        
        	name	value			
local variable	username	john.doe			
local variable	password	R6z,nUjeH];3L4r:			
local variable	uri	http://192.168.190.212:8091/api/authenticate			
&nbsp					
	schema	value			
authenticate	basic	# username& ":" & password			
&nbsp					
create http request					
&nbsp					
	uri	method	timeout	variable	expected code
send http request	# uri	GET	200	>>response	200
&nbsp					
	response	status	header	body	
parse http response	# response	>>status	>>header	>>body	
        
    
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-Rfbos7bs151wiL-O7w
    Tip:
    For Google APIs in order to retrieve the access token for OAuth 2.0, read here.
        
        	name	value			
local variable	uri	https://www.googleapis.com/gmail/v1/users/me/messages			
local variable	access token	ya29.Ci-fA76X0cjJXa2Lx0RM-fRyAQ6-6pboEX-iuT7PR-yYV6D-Rfbos7bs151wiL-O7w			
&nbsp					
	schema	value			
authenticate	oauth 2	# access token			
&nbsp					
create http request					
&nbsp					
	key	value			
add http header	Content-Type	application/json			
&nbsp					
	uri	method	timeout	variable	expected code
send http request	# uri	GET	200	>>response	200
&nbsp					
	response	status	header	body	
parse http response	# response	>>status	>>header	>>body	
        
    
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.167.29:8081/api/authenticate
  • Username: john.doe
  • Password: 123
        
        	name	value			
local variable	username	john.doe			
local variable	password	123			
local variable	uri	http://192.168.167.29:8081/api/authenticate			
&nbsp					
	schema	value			
authenticate	digest	# username& ":" & password			
&nbsp					
	uri	method	variable	timeout	expected code
send http request	# uri	GET	>>response	100	200
&nbsp					
	response	status	header	body	
parse http response	# response	>>status	>>header	>>body	
        
    
  • 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.
    1. For Basic HTTP authentication scheme: Specify username and password to authenticate with the service you are using. Follow this format userid:password.
      Tip:
      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
    2. 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
    3. 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.

Copyright © 2023 LogiGear Corporation. All rights reserved. LogiGear is a registered trademark, and Action Based Testing and TestArchitect are trademarks of LogiGear Corporation. All other trademarks contained herein are the property of their respective owners.

LogiGear Corporation

1730 S. Amphlett Blvd. Suite 200, San Mateo, CA 94402

Tel: +1(800) 322-0333