cancel
Showing results for 
Search instead for 
Did you mean: 

How to extract the access token from the 'Auth' tab and transfer it to the other requests in header?

SOLVED
Contributor

How to extract the access token from the 'Auth' tab and transfer it to the other requests in header?

I want to get the generated Access Token from the Auth tab and use it as a property for other tests. (Require to pass the access Tokens as the header for all the test steps). I want to avoid doing it manually for all the test steps.

Is it possible for me to achieve that?

Note: The access Tokens are not generated in the response. I'm using OAuth 2.0 and the tokens are getting generated in the Auth Tab.

 

Attached is the screenshot for more reference.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Contributor

Re: How to extract the access token from the 'Auth' tab and transfer it to the other requests in hea

Hi @sonya_m,

 

Support Team has provided with the answer 🙂

 

While using OAuth 2 flow, you need to select the checkbox of 'Use Authorization Header' as shown in the attached screenshot. Then, you don't need to add the token in the Headers tab Ex. Authorization: Bearer [Access Token].  After that, you can use the Auth Manager and select the respective OAuth 2 profile for your requests.

 

Thank you,

Jagruuti

 

View solution in original post

15 REPLIES 15
Highlighted
Community Hero

Re: How I can access an 'Access Token' from the 'Auth' tab.

Highlighted
Contributor

Re: How I can access an 'Access Token' from the 'Auth' tab.

Hi @nmrao,

 

I tried automating it also, I was getting an error as shown in the 'Script failure error' attachment.  Also please find the below code snippet in the other attachment.

I tried using the below code, which I think was correct. Or can you explain me which code should be added so that I can automate the manually generated token process? or is this the application related issue? Because manually the token was getting created.

 

Also, I discussed this with one of the developer in our team, he suggests this might be a configuration issue at the SOAP UI end while doing automation. 

 

Regards,

Jagruuti

 

Highlighted
Community Hero

Re: How I can access an 'Access Token' from the 'Auth' tab.

Hi @Jagruuti,

Im getting a 404 when i try downloading the .png files you attached.

Can you please either reattach or embed the details directly into your post instead?

Also. Just so we're nice and clear. You have your OAuth v2.0 setup correctly via the Auth tab on your resource or method and you want to extract the token value from this?

Nice one,

Rich
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Highlighted
Community Hero

Re: How I can access an 'Access Token' from the 'Auth' tab.

Hi @Jagruuti 

 

I'm getting a 404 when I try and download either of the code snippet or error .png files you attached.

 

Could you please either reattach or embed the contents directly into your post please?

 

I've never seen any attachments generate a 404 on this forum.  Is the upload process being blocked by an internal firewall at your end?

 

Nice one

 

rich

 

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Highlighted
Contributor

Re: How I can access an 'Access Token' from the 'Auth' tab.

Hi @richie ,

 

I'm attaching a word document from my end having both the screenshots. Please check if you can access it.

I'm changing the Subject name to be more clear. And also I have added one screenshot in the description.

 

Thanks,

Jagruti Wani

Highlighted
Contributor

Re: How I can transfer the access Token from the 'Auth' tab to other requests in the header.

 
Highlighted
Community Hero

Re: How I can transfer the access Token from the 'Auth' tab to other requests in the header.

Hey @Jagruuti,

Im struggling to understand the problem now.

Im looking at your code snippet and it looks like its a java snippet to login to a webapp front end? Im obviously missing something.

You originally mentioned that you wanted to extract the token value from the auth tab, but youve lost me now cos, well....each request can use the token cos youve setup the OAuth correctly.

Nice one!

Rich
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Highlighted
Contributor

Re: How I can transfer the access Token from the 'Auth' tab to other requests in the header.

Hi @richie ,

 

If you can see my subject's description, you can understand it better. 

 

I want to use the OAuth token in the header for more than one request and I want to avoid doing it manually.

 

** The code that I have written was for automating it. When I run the script, I'm taken to the login page of my application where I have to enter the credentials and after login, a security number will come in my inbox which I have to enter it on the next page, then the access token will get generate.

*I wanted to avoid doing it manually every time because the session time is limited for this access token.

*Also, I want to use this access token in the header of the other requests or the test steps, which also I want to avoid doing it manually. 

 

Is my problem clear now? Or do you need more details?

 

Regards,

Jagruti Wani

 

 

Highlighted

Re: How I can transfer the access Token from the 'Auth' tab to other requests in the header.

Please see below documentation to see if that is helpful

 

https://support.smartbear.com/readyapi/docs/requests/auth/index.html

 

Regards,

Ghulam

New Here?
Join us and watch the welcome video:
Announcements
TechCorner Leaderboard
Want a fun and easy way to learn ReadyAPI and show off your skills? Try solving weekly TechCorner challenges and get into the Leaderboard!


Challenge Status

Compare an expected JSON value and actual response in Events

Participate!

Fetch value/data from JSON response using Groovy Script

See replies!

Filtering data retrieved from a DataSource

See replies!

Get data from Petstore and add it to Excel sheets

Participate!
Top Kudoed Authors