# Question on Bearer Token Assignment

**URL:** <https://community.postman.com/t/question-on-bearer-token-assignment/35918>\
**Category:** Help Hub\
**Tags:** bearer-token\
**Created:** [June 3, 2022, 3:44pm UTC](https://community.postman.com/t/question-on-bearer-token-assignment/35918 "2022-06-03T15:44:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![thibaulv](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@thibaulv](https://community.postman.com/u/thibaulv)\
**Post date:** [June 3, 2022, 3:44pm UTC](https://community.postman.com/t/question-on-bearer-token-assignment/35918/1 "2022-06-03T15:44:08Z")

</div>

Hi all,

I did download a collection and environment variables for a project i am working on. I then modified the environment variables to match my lab setup and all is working.

The authorization is set to ‘Inherit from parent’. This is fine. I went to the collection folder and the Authorization is set to ‘Bearer Token’ which is expected and the Token is set to {{bearToken}}.

Now, in the collection in the Authentication folder, i can get a token successfully and i get something like this:

“access\_token”: “AgKxTqPnS82r4j…”  
“token\_type”: “bearer”,  
“expires\_in”: 299,  
“refresh\_token”: “q6duTgoLEkG7r…”

The question is: how is the access\_token that I get, automatically assigned to the {{bearToken}} ?  
Should I see somewhere like access\_token = {{bearToken}}?

In any case, when the token is expired, and i perform a request, is a new token, AUTOMATICALLY, re-fetched? Or do I start AUTOMATICALLY using the ‘refresh\_token’ value? what is the difference between the two ?

---

<div class="post-metadata">

**Author:** ![w4dd325](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/w4dd325/32/12436_2.png) [@w4dd325](https://community.postman.com/u/w4dd325)\
**Post date:** [June 3, 2022, 3:47pm UTC](https://community.postman.com/t/question-on-bearer-token-assignment/35918/2 "2022-06-03T15:47:40Z")

</div>

Hi @thibaulv

When you forked the collection, is there a pre-req script or a test script included (when you GET the token), that assigns the value to {{bearToken}}?

something like this;  
 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/3/b/3bcdccd3a90b54ff65fff6c55494a3f1a91946c3.png)

---

<div class="post-metadata">

**Author:** ![thibaulv](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@thibaulv](https://community.postman.com/u/thibaulv)\
**Post date:** [June 3, 2022, 4:23pm UTC](https://community.postman.com/t/question-on-bearer-token-assignment/35918/3 "2022-06-03T16:23:12Z")

</div>

Thanks! Yes i see this:

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/1/6/16f53068ef85c9c5132f919d2b12798eca485c14.png)

This is good. Now the next step.

In my request, i do not see {{bearToken}} anywhere. But I see this:

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/7/1/713e50de419e46e3b3904ab8b5c278ff67ff0ba7.png)

How does this {{bearToken} gets translated to the Authorization Line? I guess it knows, because in the ‘Parent’ it was set to Bearer. Is this mapped automatically ?

---

<div class="post-metadata">

**Author:** ![w4dd325](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/w4dd325/32/12436_2.png) [@w4dd325](https://community.postman.com/u/w4dd325)\
**Post date:** [June 3, 2022, 4:29pm UTC](https://community.postman.com/t/question-on-bearer-token-assignment/35918/4 "2022-06-03T16:29:04Z")

</div>

Off the top of my head without looking, if it is “inherited from parent” I would expect that to be fed in before the request is sent. (almost like a pre-req script would be).

The fact that it is a darker grey colour (the tick boxes on the left), shows it is one of the “auto-generated headers”.

You could change it if you wanted to. The ‘Bearer’ is passed as a header regardless of where the value is initially stored. you could literally put the {{bearToken}} variable in that ‘value’ field above and it would send the same token. I find the “inherit from parent” is preferred by some people but I usually submit mine just as a header.

---

<div class="post-metadata">

**Author:** ![thibaulv](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@thibaulv](https://community.postman.com/u/thibaulv)\
**Post date:** [June 3, 2022, 4:50pm UTC](https://community.postman.com/t/question-on-bearer-token-assignment/35918/5 "2022-06-03T16:50:14Z")

</div>

ok thanks. what about the expired token ? I mean do I always have to generate a token then send my request, I mean when it’s beyond 5 minutes?

---

<div class="post-metadata">

**Author:** ![w4dd325](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/w4dd325/32/12436_2.png) [@w4dd325](https://community.postman.com/u/w4dd325)\
**Post date:** [June 3, 2022, 5:04pm UTC](https://community.postman.com/t/question-on-bearer-token-assignment/35918/6 "2022-06-03T17:04:00Z")

</div>

If the token expires you will require a new one yes.

You can generate as many tokens as you like as they will include (within the cryptography) a date/time stamp that will have an expiration.
