I'm trying to create a test under a token-based authorization mechanism. Everything is almost working fine until the accesstoken is expired. Then I'm trying to refresh it, however it seems some piece of the test is not performed.
This is the Authorization dance:
foreach user in users.csv: { Get Authorization Code: Http sampler Extract AuthzCode on ${authorizationcode}: JSON extractor if ${JMeterThread.last_sample_ok} { Get Access Token: Http sampler Extract AccessToken on ${accesstoken}: JSON extractor Extract RefreshToken on ${refreshtoken}: JSON extractor if ${JMeterThread.last_sample_ok} { foreach data in data.csv { Send data in body: Http sampler if ${JMeterThread.last_sample_ok} == false ******************* { Extract error on ${expiredaccesstokenerror}: JSON extractor if (${expiredaccesstokenerror} == "expired_accesstoken") { Get new accessToken using ${refreshtoken}: Http Request Extract AccessToken on ${accesstoken}: JSON extractor Extract RefreshToken on ${refreshtoken}: JSON extractor } } } } } }
Everything works fine until the AccessToken expires and server returns me this body:
{
"error_description":"Access token expired",
"suberror":"expired_accesstoken",
"error":"invalid_grant"
}
After that, I'm expecting JMeter reach the inside if controller
with ${JMeterThread.last_sample_ok} == false
and then the next if controller
with condition ${expiredaccesstokenerror} == "expired_accesstoken"
. However I'm not able to figure out why this code is not reached.
As you can see in the herewith image, I've implemented this process in JMeter as: