# Values from console log in a OAuth2 authorization

**URL:** <https://community.postman.com/t/values-from-console-log-in-a-oauth2-authorization/64462>\
**Category:** Help Hub\
**Tags:** variables, authentication\
**Created:** [July 23, 2024, 9:54am UTC](https://community.postman.com/t/values-from-console-log-in-a-oauth2-authorization/64462 "2024-07-23T09:54:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ronaldzam31](https://avatars.discourse-cdn.com/v4/letter/r/b3f665/32.png) [@ronaldzam31](https://community.postman.com/u/ronaldzam31)\
**Post date:** [July 23, 2024, 9:54am UTC](https://community.postman.com/t/values-from-console-log-in-a-oauth2-authorization/64462/1 "2024-07-23T09:54:23Z")

</div>

Hello, nice to greet all of you.

I have an scenario in wich I need the values from console log, to set some environment variables.

So, in my case, the Authorization is using OAuth2.0 feature - Request URL. When I get a access\_token, using the feature in the same authorizarion tab, all the OAuth process happens and is recorded in the console log.

From console log, I need:

- From the firts GET after the consent, I need to extract the auth\_code in the response headers, and set it in a variable.
- From the POST, extract the access\_token and id\_token, and set in a variable.

NOTE: important to clarify, till this moment I didn’t made any request to the API, because I’m still in the Authorization Tab.

Could anyone help me, please?

Best, regards.

---

<div class="post-metadata">

**Author:** ![gbadebo-bello](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/gbadebo-bello/32/12175_2.png) [@gbadebo-bello](https://community.postman.com/u/gbadebo-bello)\
**Post date:** [July 24, 2024, 10:51am UTC](https://community.postman.com/t/values-from-console-log-in-a-oauth2-authorization/64462/2 "2024-07-24T10:51:39Z")

</div>

Hi @ronaldzam31. Welcome to the Postman Community.

Are you making use of our [OAUth 2.0 helper?](https://learning.postman.com/docs/sending-requests/authorization/oauth-20/). If yes, the access token can be stored in a variable and refreshed automatically.

However, to store the authorization code and id\_tokens, you will need to manually build an Oauth flow from scratch in Postman and write some scripts to store these values in the appropriate environment variables yourself.

---

<div class="post-metadata">

**Author:** ![ronaldzam31](https://avatars.discourse-cdn.com/v4/letter/r/b3f665/32.png) [@ronaldzam31](https://community.postman.com/u/ronaldzam31)\
**Post date:** [July 24, 2024, 11:10am UTC](https://community.postman.com/t/values-from-console-log-in-a-oauth2-authorization/64462/3 "2024-07-24T11:10:47Z")

</div>

Hello @gbadebo-bello, thank for your response.

Yes, I used OAuth2.0 helper.

My flow is Authorization Code with PCKE Grant, for this reason build from scratch the first GET to build the Authorization Code isn’t possible (or I don’t know how to).

Greetings,

---

<div class="post-metadata">

**Author:** ![gbadebo-bello](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/gbadebo-bello/32/12175_2.png) [@gbadebo-bello](https://community.postman.com/u/gbadebo-bello)\
**Post date:** [July 24, 2024, 12:04pm UTC](https://community.postman.com/t/values-from-console-log-in-a-oauth2-authorization/64462/4 "2024-07-24T12:04:03Z")

</div>

Hi @ronaldzam31.

The first step is possible, but it has to be a manual process and can’t be automated. The initial Authorization request to get the authorization grant is a GET request that loads an authorization screen. That can be done in a GET request in Postman or by copy and pasting the URL(with all necessary scopes and redirect URI) in the browser. After you input your credentials, and you have been redirected, you can copy the authorization code from the query parameters in the URL and store that in an environment variable.

Ideally, you only need the authorization code once. Once you are able to get your access token, you can always use your refresh token to get a new access token.

---

<div class="post-metadata">

**Author:** ![ronaldzam31](https://avatars.discourse-cdn.com/v4/letter/r/b3f665/32.png) [@ronaldzam31](https://community.postman.com/u/ronaldzam31)\
**Post date:** [July 26, 2024, 9:23am UTC](https://community.postman.com/t/values-from-console-log-in-a-oauth2-authorization/64462/5 "2024-07-26T09:23:04Z")

</div>

Thank you very much @gbadebo-bello, I build the flow from scratch.

Greetings,
