# Get OAuth2 token in variable

**URL:** <https://community.postman.com/t/get-oauth2-token-in-variable/28873>\
**Category:** Help Hub\
**Tags:** authentication\
**Created:** [October 19, 2021, 3:12pm UTC](https://community.postman.com/t/get-oauth2-token-in-variable/28873 "2021-10-19T15:12:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeffwalker-rxb](https://avatars.discourse-cdn.com/v4/letter/j/e9c0ed/32.png) [@jeffwalker-rxb](https://community.postman.com/u/jeffwalker-rxb)\
**Post date:** [October 19, 2021, 3:12pm UTC](https://community.postman.com/t/get-oauth2-token-in-variable/28873/1 "2021-10-19T15:12:53Z")

</div>

How can I get the result of the OAuth2 authorization token into a variable?

I’ve successfully set up the auth for my collection, getting the token that’s automatically put in the header as a bearer token.

We have this security service that has an introspection end point, you pass the token in a request parameter and it tells you details about it. I want to get he token as a variable.

We’re using the auth code grant, so I don’t want to do this manually in the pre-request script if I can help it.

---

<div class="post-metadata">

**Author:** ![bpricilla](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/bpricilla/32/6511_2.png) [@bpricilla](https://community.postman.com/u/bpricilla)\
**Post date:** [October 21, 2021, 1:01pm UTC](https://community.postman.com/t/get-oauth2-token-in-variable/28873/2 "2021-10-21T13:01:15Z")

</div>

@jeffwalker-rxb Welcome to the Community 🥳

Yes, you just need to store that as [variable](https://learning.postman.com/docs/sending-requests/variables/) and use it the subsequent requests.

There’s lot of questions related to in the forum. This [post](https://community.postman.com/t/medium-article-how-to-automate-oauth2-token-renewal-in-postman/6630/2) will be super useful to you.
