thunder-client-support icon indicating copy to clipboard operation
thunder-client-support copied to clipboard

oAuth2 Authorization token flow improvements

Open m-schrepel opened this issue 1 year ago • 1 comments
trafficstars

Please describe feature/problem details and the solution you'd like. We use a custom authorization header instead of Authorization, which means when we use the oAuth2 flow, we have to manually copy and paste the token to an environment variable.

A possible solution would be: Allow for defining a header other than Authorization in the advanced part of the oauth2 flow.

Another solution would be to make the post-request scripts work with the authorization requests. This way we could set a dynamic variable in memory.

Describe alternatives you've considered I tried something like this

tc.request.setHeader('Custom-Header', tc.request.getHeader('Authorization'))

which also doesn't work and would be another viable solution to our issue

Are you using the free version/paid version/trial: Enterprise customer

m-schrepel avatar Jul 01 '24 15:07 m-schrepel

Thanks @m-schrepel for the feedback. I will review and add to the roadmap.

rangav avatar Jul 01 '24 15:07 rangav

This feature has been implemented and published to the marketplace. Please update to v2.25.7.

You can see all the features released in this update https://github.com/rangav/thunder-client-support/releases/tag/v2.25.7

Please test it and let me know your feedback

rangav avatar Sep 21 '24 18:09 rangav

@rangav for the oauth2 improvements, can I access the OAuth2 tab via scripting?

This doesn't work: const accessToken = tc.request.auth.oauth2.get('accessToken')

Error in Pre Request Script: - Cannot read properties of undefined (reading 'oauth2')

aagranovExtend avatar Sep 24 '24 20:09 aagranovExtend

@aagranovExtend Currently not possible, I will add it in the next update.

rangav avatar Sep 25 '24 15:09 rangav

We published new update to add further improvements in v2.25.8

New Additions:

  • Access authorization header in Post Req Script - tc.request.getHeader('Authorization')
  • Added auth property to request model in script. To get access token use this - tc.request.auth.oauth2.accessToken. Log auth property using console.log(tc.request.auth) to see all props available.

rangav avatar Sep 25 '24 18:09 rangav