I am unable to use OAuth 2 token generated in JMeter to execute following requests.
I am able to successfully POST to our identity server and obtain a token, capture it using a JSON Extractor, and pass that variable to a following GET call. But every time I execute the Test Plan, I get a 403 error on the GET call.
What is strange, is if I obtain a OAuth 2 token from Postman using the same parameters, copy the token from Postman, and then update my GET request in JMeter to use that token, it works.
I have tried to record in JMeter the POST and GET calls from Postman, but it results in same 403 error. The token only works if I get it from Postman first.
CodePudding user response:
Apologies to the cloud. I was not setting the correct port number for https request on the following GET Request after obtaining a OAuth 2 token.
CodePudding user response:
As per HTTP status 403 description:
The HTTP 403 Forbidden response status code indicates that the server understands the request but refuses to authorize it.
it means that your token works somehow (otherwise you would get HTTP Status 401 instead) you just don't have sufficient permissions to do what you want to do.
The fact that request works in Postman is weird indeed, most probably you're not sending the same request so I would recommend just recording the request originating from Postman using JMeter's HTTP(S) Test Script Recorder and after implementing the proper correlation of dynamic parameters (it might be not limited to the token only) you should get exactly the same result you're getting in Postman.