0

How to generate OAuth2.0 access tokens in Jmeter.?

I'm able to get the setup for Postman using OAuth2.0. However, when I want to test these and develop script in JMeter, I am unable to get through it. enter image description here

This postman setup doesnt ask for client_secretKey only required client_Id, instead it pops up a window where I enter the username and password and then it is redirected/called back to my application URL. When I looked into the URL, it has the following parameters

https://product.auth0.com/authorize?
redirect_uri=abc.com
client_id=XXX
errorPath=%2Ferror
scope=openid%20profile%20email%20offline_access
response_type=code
response_mode=query
state=dynamicvalue1
nonce=dynamicvalue2
code_challenge=dynamicvalue3
code_challenge_method=S256
auth0Client=staticvalue HTTP/1.1

I know client_secretKey, now I am wondering if I can able to get to the authorisation/authentication of the application by using the client ID, secretKey grant type etc?

Please suggest on ways I can connect to and access the application.

Y5288
  • 163
  • 1
  • 14
  • Does this answer your question? [How to do a OAuth 2.0 authentication in JMeter?](https://stackoverflow.com/questions/41818784/how-to-do-a-oauth-2-0-authentication-in-jmeter) – SiKing Jan 09 '23 at 21:14
  • Yes, I did try it but in JMeter, I get the Invalid JSON response. I have made couple of trials with the parameters and URL, but wasn't giving proper response. – Y5288 Jan 09 '23 at 21:21

1 Answers1

1

Postman is a browser plugin, JMeter is not a browser hence it cannot "pop up w window"

The easiest way of capturing the network requests from Posman in JMeter is just recording it using JMeter's HTTP(S) Test Script Recorder.

  1. Start JMeter's HTTP(S) Test Script Recorder

  2. Import JMeter's certificate into Postman

    enter image description here

  3. Configure Postman to use JMeter as the proxy

    enter image description here

  4. Run your request in Postman.

  5. JMeter should generate proper HTTP Request sampler and HTTP Header Manager and you should be able to replay the request.

  6. Identify the dynamic parameters and perform their correlation

  7. You should be able to replay the authorization flow using JMeter now.

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • Thanks again @Dmitri for your valuable inputs. I have used POSTMAN as per your suggestion and also the CHrome network tab to get through the list of HTTP requests and I am able to successfully recreate the Oauth2.0 flow for the application. – Y5288 Jan 12 '23 at 16:42