Search code examples
groovyoauth-2.0jmeterpkce

For OAuth PKCE flow in JMeter unable to extract Code values


In JMeter unable to extract the code_verifier and code_challenge values.

Referred this post, How to generate Authorization code in Jmeter with Oauth PKCE flow

but while executing the code getting error as, "ERROR o.a.j.m.JSR223PreProcessor: Problem in JSR223 script, JSR223 PreProcessor - code_challenge javax.script.ScriptException: javax.script.ScriptException: java.lang.NullPointerException: Cannot invoke method getBytes() on null object"


Solution

  • If you're blindly copying and pasting the code from the referred answer - make sure to copy and paste the code_verifier piece as well because the error you're getting most probably means that verifier variable is null (doesn't have respective value)

    Make sure to properly generate the verifier variable and ensure that it's there by checking jmeter.log file (look for code_verifier line) and/or by adding a Debug Sampler which allows inspecting which JMeter Variables are defined and see their values