Invalid Access Token - Using Collection Runner

Novice attempting to return to the use of Postman to extract data after about a year and getting re-acquainted.

Receive an error upon using the Collection Runner to pass longitude and latitude coordinates from a CSV file.

The error received is “JsonError: No data, empty input at 1:1.”
.
Upon review of the console, I see “invalid access token.”

Have not been able to determine what the cause of the error is but thinking that it may be related to how Postman is capturing the access token.

Able to succesfully extract data using a single longitude/latitude coordinate manually.

But, I continually receive an error when using the Collection Runner.

Any insight as to a possible resolution?

Thanks in advance.





How is the authentication working? How is your access_token set?

When you look at the console logs, are the details from the data file being transposed correctly? Is the authentication header being sent?

The error message normally means that you are trying to parse the response, but the response isn’t JSON. (Potentially a blank response if the authentication isn’t working).

However, the code you’ve provided isn’t parsing the response. Do you have any code set at the folder or collection level that does?

Upon obtaining Access token using Precisely request “Post OAuth Token,” I access each request that I want to run and manually paste the Access token into the text box on the Authorization tab.

Then, I click “Save”

Did modify the script for Post Test (note attached) and the error remains - “Invalid Access Token.”

Access token is not expired.

Access token is correctly pasted into the text box under the Authorization tab for each request I desire to run.

Deleted cache.

Note, also attempting to pass the response to a environment variable, “responseData.”

Renamed the variable “responseData” to “responseData2.”

Saved and re-ran.

Error remains.

Manually, I am able to run using one longitude/latitude coordinate.

Thanks in advance for any additional insight.


What response codes are you getting?

It sounds like the issue is with the authentication, and therefore the response body is not JSON, causing the error in the scripts when you try to parse the response.

Is the bearer token in the Authorization header look correct. Is the console logs the same as the variable?

Can you show the Authorization tab please.

Also, are the longitude and latitude variables being transposed correct. Are the console logs showing the expected values in the URL.

Deleted the request and starting over.

Appears that the issue is with the authenticatiion of the API in Postman after acquiring the Access Token.

After clicking “Get Access Token”, I successfully acquire a access token.

Then, I go to the Headers tab and the Access Token is displayed after “Bearer” on the “Authorization” Line.

Have read that I should go to the Authorization API in Postman and paste the Access Token in the POST URL and click send to get the response.

But, for an Auth Type of OAuth 2.0, I am not readily seeing where to access the Authorization API.

Attached are several screen prints of the Authorization tab, Headers tab, Global variables, environment variables, etc.

Note, I have not re-created the request that uses the CSV data file that includes a list of Longitude and Latitude coordinates yet.

I am focusing on first finalizing the authenticaton of the API using the request that manually extracts the data.

Thanks in advance for any future insight that will assist in the resolution of this issue!





Also reviewed the Console log upon clicking “Send” after acquiring the Access Token.

Will continue to trouble shoot for another day or so before considering the the use of R, Python and/or an alternative to Postman to access the API to determine if I can authenticate the API after receiving an Access Token.


The first screenshot is showing a 404 not found error, not an authentication error.

This usually means the URL is wrong, rather than a failed authorization attempt which usually generates a different status code.

You appear to have a request to the token endpoint, plus the authorization helper. You don’t have both, its either a fully fledged request to the token endpoint, or you use the Authorization helper.

Looking at the Precisely API documentation, the URL looks ok.

Generating an OAuth Token (precisely.com)

Are these the instructions you are following? The auth is not using a bearer token. Is using basic auth with a base64 encoded string generated from your API key and secret.

The API also states that the content type is application/x-www-form-urlencoded. Its not a JSON request. In the body the documentation states “grant_type=client_credentials” which doesn’t quite make sense (as that looks like a query parameter). So it looks like a bit of trial and error related to that item may be needed.

I think the request needs to look like the following.

image

The Authorization is also slightly confusing, as Basic auth is normally a username and password encoded into a Base64 string.

Postman can do this from the authorization helper.

image

In your case, the Username sounds like it should be the API key and the secret should be the password.

If that doesn’t work, just setup the header manually. It should look something like.

image

Store the actual Base64 encoded string in an environment variable (so its secure).

If I send using this method with a made up Base64 encoded string. I get the expected 401 Unauthorized status. (Instead of the 404 not found, you are getting).

image

The issues you are facing are API usage issues. So you’ll have the same issues using Python or any other method.

You need to call the token end point to get an access_token. That access_token is the bearer token for the subsequent requests.

I’m not a developer, but it doesn’t look like precisely is strictly following the OAuth 2.0 implementation rules. So you might need to do this as a full request, as I think the helpers will struggle with the non-standard implementation. Suspect there will be an amount of trial and error here.