I want to utilize oAuth2 for a token POST request. I do not see any native support for this authorization format. I think a custom keyword may be the way but I need advice. I have created in the Object Repository a Token Post request, and it works, when I manually add an Authorization in HTTP Headers ( contains realm, basic logon parameters, timestamp and nonce…) and it returns the Token. My question is, How can I execute a groovy script within a custom keyword to generate the Authorization values and post them to the Authorization field in the HTTP Headers of my Object (Token_oAuth in the Repository ) or could I run a script inline of the test case to generate the Authorization string values and then add them to the Token_oAuth Object as it is called perhaps as a parameter ?
Thank you for your response, however The name of my Web Service request has changed to POST because I recreated each portion and verified their functionality prior to responding . The web Service does function as expected when configured with hard coded values (set in the web service) my issue is setting the value of the HTTP Headers ‘Authorization’ from the script within the test case.
So using the example above the line “header.setValue(‘Basic realm=MyPage.NET&grant_type=password&username=user@tran.net&password=password×tamp=1486664262&nonce=CgCHNY&client_id=abcef0123456789’)” is failing to set the value. I also note that failure does not throw an error or exception. I have tried passing both variables with assigned strings, and as shown a hard coded string, with no change. The value is not assigned to the Authorization header in the Web service request.
I have tried both options, but with no success. Neither adding a string value to the preexisting HTTP header ‘Authorization’ or adding the Header value ‘Authorization’ + string value worked for me. I am using Katalon Studio Version: 4.4.0 Build: 1.
When I run the test I am returned a 400 error, and when i open the WebServiceRequest I see the property has not value.
I am using this script. the Web service request is called POST (its an oAuth2 POST request, I am wanting to add a string value to the HTTP Header, ‘Authorization’)
RequestObject tokenOAuth = findTestObject(‘POST’)
for (TestObjectProperty header : tokenOAuth.getHttpHeaderProperties()) {
if (header.getName().equals(‘Authorization’)) {
header.setValue(‘Basic realm=MyPage.NET&grant_type=password&username=user@tran.net&password=password×tamp=1486664262&nonce=CgCHNY&client_id=abcef0123456789’)
It does appear the even though no error is thrown, I cannot add a value to the HTTP Headers ‘Authorization’ or add a header as in either of your examples. Am I missing something environmental?
run a script inline of the test case to generate the Authorization string values and then add them to the Token_oAuth Object as it is called perhaps as a parameter
Example:
// need to import com.kms.katalon.core.testobject.RequestObject// need to import com.kms.katalon.core.testobject.TestObjectPropertyRequestObject tokenOAuth = findTestObject('Your Token_oAuth ID')// Option 1: tokenOAuth already has Authorization header valuefor (TestObjectProperty header : tokenOAuth.getHttpHeaderProperties()) { if (header.getName().equals('Authorization')) { header.setValue('Your new token value') break }}// Option 2: tokenOAuth has none Authorization header value// need to import com.kms.katalon.core.testobject.ConditionTypetokenOAuth.getHttpHeaderProperties().add(new TestObjectProperty('Authorization', ConditionType.EQUALS, 'Your token value'))
I started using katalon studio and automated many rest api’s using normal authorization. But recently they moved to Aouth2.0 and i need to migrate all these to Aouth2.0.
i tested same in postman which is working fine. But i would like to use Katalon studio for Aouth2. Can anyone help me how to use it in katalon studio.
any help is appreciated.
Thanks for oauth2 implementation in katalon beta version.
I tested this feature and sometimes the genarated token giving 500 error. The token is working inconsistently with 500 error.
Not sure what is the issue.
But you guys did a great job. And when this will be available in current version?
Thanks for your feedback. The feature should be available by March at the latest.
By the way, can you help provide us more details about the 500 issue you encountered?
Thanks for the quick reply. Happy for the oauth2 feature and great it is coming in March.
Regarding 500 error, i checked it multiple times and understood it is a internal server issue.
Now i am using this feature in beta version to get access token which is working perfectly fine.
Now i want to automate this access token generation process using scripts/code/custom keyword, instead of filling the data under authorization tab manually.
Can you help me how to automate this process.
Note: I want to fill the data as shown in the pics below and with out using Request Token button, it is possible to access this information by calling object repository and generate the url and hit in the browser and login , then get the code and pass it to token url which will give access token.