Unable to authenticate application with a bearer token

Hi there,

I’ve generated a bearer token and am sending the following request:

GET /v1/live/hazards/roadwork/open HTTP/1.1
Host: api.transport.nsw.gov.au
Authorization: Bearer f…
Cache-Control: no-cache

Here is the response I receive:

{
    "ErrorDetails": {
        "TransactionId": "00000154124922b7-b38f",
        "ErrorDateTime": "2016-04-18T12:23:32.609+10:00",
        "Message": "The calling application is unauthenticated.",
        "RequestedUrl": "/v1/live/hazards/roadwork/open",
        "RequestMethod": "GET"
    }
}

For complete clarity, I’m sending the GET request to https://api.transport.nsw.gov.au/v1/live/hazards/roadwork/open with the bearer token in the authorization header (i.e. no additional query strings in the URL). I’ve assigned the ‘Roads - Realtime - Hazards’ API to my application, so at this point I’m not sure what I’m doing wrong.

Any ideas?

(Edit: I know I can get the roadwork hazards file at this URL but I’m getting this error for ALL services (e.g. realtime transport) so that’s not a solution.)

Hi Tim

Have you tried via the API Explorer?

Also make sure you are following the details from the Getting Started User Guide
https://opendata.transport.nsw.gov.au/site/en_us/gs-intro.html

We’re having a look to see if we can replicate the issue so can see what you may be doing differently.

Hey Tim

OK in your Test Application you need to include the callback URL and Scope and change the scope to Confidential.
Details can be found in the User Guide.

Seems like we should add some extra “How to” guides in this forum.

Let us know how you go.

Hi Yvonne,

Thanks for the quick response. That was clearly user error because I didn’t follow this step:

Fill in the fields with the following details:
Callback/Redirect URL - Provide the Callback/Redirect URL for your application (e.g. https://developer.transport.nsw.gov.au/admin/oauthCallback)
Scope = user
Type = Confidential
Click Create

I set the Scope to user, added a Callback URL, and set the Type to Confidential and I’m now receiving data.

1 Like