Get access token and make API call

Looking for sample code to run the gatling.sh script that will get an access token from a URL endpoint and then use the token to make an API call.
Grant type: client_credentials
client_id, client_secret with

Hi @Flipper ,

Hope this helps.
I am getting the CSRF token from the session and passing it forward as a parameter.
It depends on how you are using the TOKEN.

       .exec(http(<endpoint>)
        .get(<endpoint>)
        .check(status.is(200))
        .check(css("meta[name='_csrf']", "content").saveAs("CSRF_TOKEN")))
      //.check(regex("name=\"_csrf\" content=\"(.+?)\"").saveAs("CSRF_TOKEN"))
      .exec(session => {
          val response = session("CSRF_TOKEN").as[String]

Or you can attend the free courses of Gatling Academy where it’s explained in details.

Cheers!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.