Search code examples
apirestready-api

How can I take a generated token from a Test Suite and add it as an Authorization header?


I'm having an issue with a readyAPI project i'm migrating. I'm not a backend-lover so it's quite diff from my perspective, hope you guys have another pov and can give me a hand.

Here's the issue: From the first TestSuite I got a Bearer token which I use to authenticate in each next service. Problem is that I do not know how to take this token from the first test without setting it manually into the next service's properties. I mean, I want the token to be setted automatically without the need of setting it manually.

Here's how I got the token

I've this groovy script but I do not know how it exactly works (I didn't created it)

So I think that by variables I can get the token from the first test but I'm not really sure on how to adapt it. I think that I need to add to this variable the "Bearer " words to make it work, but I cannot see the how to.

Sorry if im not being clear, I'll be glad to add any further information if you guys can help me :)

Thank you very much in advance.


Solution

  • Well I added a "Bearer " + to the Groovy script that was implemented and then an Authorized test step to the next tests and it worked! :) If anyone need more info about this workaround I'll be glad to share it.