4
votes

Does any one knows how to solve it with regular expression? here i am putting screen shot with valid access token and error response token. thanks in advance.

Valid response token

enter image description here

invalid response token

enter image description here

and Regular expression exctracter enter image description here

it is fine if you guys have any other solution for this unauthorized access thing.

1
Add text of responses , and do you need regular expression for success/failed or both?user7294900
only success. I have try to add responses but failed. can you help you with a query ?kunal soni
what you need to find only access_token? did you try to find similar questions? for example stackoverflow.com/questions/46690181/…user7294900
i have tried this. prntscr.com/hj83au , prntscr.com/hj83f7 but it is not working , still facing 401 error.kunal soni

1 Answers

3
votes
  1. Add JSON Extractor as a child of the authserver request and configure it as follows:

    • Variable Names: anything meaningful, i.e. token
    • JSON Path expressions: $.access_token
  2. Add HTTP Header Manager as a child of the student request and configure it to send Authorization header with the value of Bearer ${token}

Going forward you can go for an alternative way of recording a JMeter test which is capable of exporting the recorded requests in SmartJMX mode with automatic correlation of dynamic parameters applied so you will be able to save your time for more creative work. See How to Cut Your JMeter Scripting Time by 80% article for more details.