# Real noob question: how to get a bearer token?

**URL:** <https://community.postman.com/t/real-noob-question-how-to-get-a-bearer-token/29709>\
**Category:** Help Hub\
**Tags:** bearer-token\
**Created:** [November 15, 2021, 9:48am UTC](https://community.postman.com/t/real-noob-question-how-to-get-a-bearer-token/29709 "2021-11-15T09:48:46Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [November 15, 2021, 1:11pm UTC](https://community.postman.com/t/real-noob-question-how-to-get-a-bearer-token/29709/6 "2021-11-15T13:11:35Z")

</div>

The Collection you have isn’t really in the right order, to be honest, as you would need a token first, to authenticate yourself against the other endpoints of the API.

From the Quickstart guide:

> **[Bank Account Data](https://gocardless.com/bank-account-data/)**

The first thing you do is make a POST request to the `https://ob.nordigen.com/api/v2/token/new/` with the secret values that you have most likely got from creating an account with that service.

> First, you’ll need to get your user secret from [Nordigen’s Open Banking Portal](https://ob.nordigen.com/user-secrets/) in section User Secrets. Use those secrets to create an access token (referenced as ACCESS\_TOKEN in the following steps).

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/9/e/9e6547e953fcf424cf33936757b2654526e1f227.png)

The response of this is going to be the token information that you will use to make a request to a different endpoint.

```auto
{
  "access": "someSecretValue",
  "access_expires": 86400,
  "refresh": "someRefreshSecretValue",
  "refresh_expires": 2592000
}

```

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/d/b/dbd384307b494a50abfa8646b18ef6036e79933b.png)

In this example from the Quickstart guide, the `ACCESS_TOKEN` value, is the same value as the `token` value from the response of the first request. This has an expiry time (I think it’s 24 Hours) so once that’s run out, you will need to request a fresh token and reset the clock.

There are different methods of automatically extracting the response values into a variable and using that in the headers, I would initially get this working by hardcoding the values first and then refactoring what you have.

* * *

Once you’re ready, you can get the token by adding this to the `Tests` section of the token request:

```auto
pm.globals.set('token', pm.resonse.json().token);

```

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/d/d/dd0286aa6a241d638414790c4fdea91b70982292.png)

You will then be able to use the variable syntax to replace the header values:

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/3/9/3985a5008f633468229804044961b30f40d1af10.png)

---

_[View the full topic](https://community.postman.com/t/real-noob-question-how-to-get-a-bearer-token/29709)._
