# Issue getting token to work

**URL:** <https://opendataforum.transport.nsw.gov.au/t/issue-getting-token-to-work/2536>\
**Category:** How to\
**Created:** [September 15, 2021, 1:17am UTC](https://opendataforum.transport.nsw.gov.au/t/issue-getting-token-to-work/2536 "2021-09-15T01:17:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![radiomedia](https://avatars.discourse-cdn.com/v4/letter/r/8dc957/32.png) [@radiomedia](https://opendataforum.transport.nsw.gov.au/u/radiomedia)\
**Post date:** [September 15, 2021, 1:17am UTC](https://opendataforum.transport.nsw.gov.au/t/issue-getting-token-to-work/2536/1 "2021-09-15T01:17:20Z")

</div>

So I am trying to fetch the NSW fuel data, and I am running into issues about how we authorise and then use that token in the next step.

Basically the token I received in the first step

```auto
{
  "refresh_token_expires_in": "0",
  "api_product_list": "[Fuel Check Portal Api]",
  "api_product_list_json": [
    "Fuel Check Portal Api"
  ],
  "organization_name": "onegov",
  "developer.email": "russell@EMAIL.com",
  "token_type": "BearerToken",
  "issued_at": "1631666514337",
  "client_id": "CLIENT_ID",
  "access_token": "ACCESS TOKEN",
  "application_name": "XXXXX-XXX-XXXX-XXX-XXXXXX",
  "scope": "",
  "expires_in": "43199",
  "refresh_count": "0",
  "status": "approved"
}

```

I then use the access token along with the API key that I have to request.

```auto
curl -X GET "https://api.onegov.nsw.gov.au/FuelPriceCheck/v1/fuel/prices" -H "accept: application/json" -H "Authorization: ACCESS_TOKEN" -H "Content-Type: application/json; charset=utf-8" -H "apikey: API_KEY" -H "transactionid: 716" -H "requesttimestamp: 2021-09-15T00:40:42Z"

```

The response I am getting is.

```auto
{
  "errorDetails": {
    "code": "TokenValidationError",
    "message": "Access token is not valid."
  }
}

```

I don’t know how the access token is not valid if I just requested it.

Is it because my timestamp requesttimestamp: 2021-09-15T00:40:42Z

---

<div class="post-metadata">

**Author:** ![radiomedia](https://avatars.discourse-cdn.com/v4/letter/r/8dc957/32.png) [@radiomedia](https://opendataforum.transport.nsw.gov.au/u/radiomedia)\
**Post date:** [September 15, 2021, 3:36am UTC](https://opendataforum.transport.nsw.gov.au/t/issue-getting-token-to-work/2536/2 "2021-09-15T03:36:21Z")

</div>

Seems the issue is not with the code, but with the try now page on open data.  
When I used the code and did a GET request in Postman it worked fine.

---

<div class="post-metadata">

**Author:** ![jyoung6](https://avatars.discourse-cdn.com/v4/letter/j/9de053/32.png) [@jyoung6](https://opendataforum.transport.nsw.gov.au/u/jyoung6)\
**Post date:** [September 16, 2021, 12:41am UTC](https://opendataforum.transport.nsw.gov.au/t/issue-getting-token-to-work/2536/3 "2021-09-16T00:41:11Z")

</div>

Hi radiomedia,

Welcome to the Open Data Forum! The Fuel Check API is not owned by Open Data, we just link to it. I have submitted your enquiry via the Support link on [API Product | welcome to api.nsw](https://api.nsw.gov.au/Product/Index/22). I will keep you updated.

Regards,  
Julie

---

<div class="post-metadata">

**Author:** ![jyoung6](https://avatars.discourse-cdn.com/v4/letter/j/9de053/32.png) [@jyoung6](https://opendataforum.transport.nsw.gov.au/u/jyoung6)\
**Post date:** [September 16, 2021, 2:53am UTC](https://opendataforum.transport.nsw.gov.au/t/issue-getting-token-to-work/2536/4 "2021-09-16T02:53:47Z")

</div>

Hi radiomedia,

I have received the following response:

> The header value should be :
> 
> Authorization: Bearer ACCESS\_TOKEN

Could you let me know if this works?

Thanks,  
Julie
