OAuth API Testing With JMeter
This article talks about how to test OAuth API's using JMeter 5.1. There are two major steps involved in OAuth testing. Find out more!
Join the DZone community and get the full member experience.
Join For FreeFor Installing and Overview of JMETER. Please check
https://dzone.com/articles/jmeter-tutorial-for-beginners-jmeter-load-testing
This article talks about how to test OAuth API's using JMeter 5.1
There are two major steps involved in OAuth testing:
1. Request for Token.
2. Use that token in Subsequent API as Bearer Token in the Header.
Assumption
You already reviewed the above Article before proceeding to the next steps.
Step 1: Request for a Token.
a) Right-Click the "Test Plan" and Add a new thread group. Name it as "Demo Group"
b) Right-Click the "Thread Group" --> Add --> Sampler --> HttpRequest
c) Add Request details and "Save"
d) Add "View Result Tree" & "JSON Token Extrator"
e) Now add the JSON Path Expression where you can find the token (from View Result tree --> Response).
This is my response in "View Result Tree".
{"user_context":null,"return_type":"json","access_token":"qubyczsmjbttg49rtwvbka","token_type":"bearer","expires_in":3600,"refresh_token":"cjpam8qgsd3kkbyypkfrvq6e","scope":null,"state":null,"uri":null,"extended":null}
So I added $.access_token path to the variable C_Token.
Step 2: Pass that Token to the Subsequent API's
a) Follow the same Step above to create an HTTP Request and add the second API
b) Add "HTTP Message Header" and "View Result Tree"
c) Now Add the token value which you got in Step 1 - e as ${C_Token}
Follow similar steps for the remaining API.
Happy testing!
Opinions expressed by DZone contributors are their own.
Comments