Search code examples
oauth-2.0jmeterazure-active-directory

JMeter Performance testing is failing at OAuth2 authorization - Token expired


We are doing load testing on a portal which uses Azure AAD authentication using JMeter and it is currently failing with this issue:

{"error":"invalid_grant","error_description":"AADSTS70008: The provided authorization code or refresh token has expired due to inactivity. Send a new interactive authorization request for this user and resource.\r\nTrace ID: e4af3a0a-84cc-4f7e-854f-09XXXXXX9a00\r\nCorrelation ID: 54b8a5fd-b1ea-4c1f-bfe0-505XXXXXX944\r\nTimestamp: 2022-06-21 12:14:23Z","error_codes":[70008],"timestamp":"2022-06-21 12:14:23Z","trace_id":"e4af3a0a-84cc-4f7e-854f-0975ea5a9a00","correlation_id":"54b8a5fd-b1ea-4c1f-bfe0-5058478be944","error_uri":"https://login.windows.net/error?code=70008"}

Could you please help us troubleshoot the above issue?


Solution

  • If you recorded the test scenario using JMeter's HTTP(S) Test Script Recorder - at some point you won't be able to replay the test as OAuth tokens have limited life time.

    You will need to go through full authentication flow until you get the new token, extract it from the response using suitable JMeter Post-Processor, store it into a JMeter Variable and replace recorded token value with the variable holding the token.

    The process is known as correlation and there is a lot of information on the topic in the Internet.