# Invalid Access Token - Using Collection Runner

**URL:** <https://community.postman.com/t/invalid-access-token-using-collection-runner/63339>\
**Category:** Help Hub\
**Tags:** variables, collections, authentication\
**Created:** [July 3, 2024, 3:49am UTC](https://community.postman.com/t/invalid-access-token-using-collection-runner/63339 "2024-07-03T03:49:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![cetspace25](https://avatars.discourse-cdn.com/v4/letter/c/a8b319/32.png) [@cetspace25](https://community.postman.com/u/cetspace25)\
**Post date:** [July 3, 2024, 3:49am UTC](https://community.postman.com/t/invalid-access-token-using-collection-runner/63339/1 "2024-07-03T03:49:28Z")

</div>

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.

 ![20240702_Postman Error_Environment_ENV_4_7 of 7 - Copy](https://us1.discourse-cdn.com/getpostman/original/3X/1/2/12786d17e4328617e09718764350bc53f5969df0.png)  
 ![20240702_Postman Error_Environment_Global_6 of 7 - Copy](https://us1.discourse-cdn.com/getpostman/original/3X/7/f/7f8ea1fa3b701608ecdecd44e183da2f503be1c7.png)  
 ![20240702_Postman Error_Post test Script_5 of 7 - Copy](https://us1.discourse-cdn.com/getpostman/original/3X/8/e/8e294cbe8c28c067538e8435b048af7eb209e345.png)  
 ![20240702_Postman Error_Pretest Script_4 of 7 - Copy](https://us1.discourse-cdn.com/getpostman/original/3X/2/3/230ff9e51960ddeb9e913bb15908a59dc64ea849.png)  
 ![20240702_Postman Error_Parameters_3 of 7 - Copy](https://us1.discourse-cdn.com/getpostman/original/3X/6/1/6144f81bf60c891e3eccc194d11eeb036cd204fb.png)

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [July 3, 2024, 11:00am UTC](https://community.postman.com/t/invalid-access-token-using-collection-runner/63339/2 "2024-07-03T11:00:58Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![cetspace25](https://avatars.discourse-cdn.com/v4/letter/c/a8b319/32.png) [@cetspace25](https://community.postman.com/u/cetspace25)\
**Post date:** [July 3, 2024, 11:42pm UTC](https://community.postman.com/t/invalid-access-token-using-collection-runner/63339/3 "2024-07-03T23:42:50Z")

</div>

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.

 ![20240703_Postman Error_Console Log - Copy](https://us1.discourse-cdn.com/getpostman/original/3X/6/0/60a0998b6708e2ca31499837a0bba5f5e26e0722.png)  
 ![20240703_Postman Error_Updated Post Test Script - Copy](https://us1.discourse-cdn.com/getpostman/original/3X/7/2/7263f85a5f77b01b1346ebc52fef5c0ee8f0d1c1.png)

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [July 4, 2024, 10:05am UTC](https://community.postman.com/t/invalid-access-token-using-collection-runner/63339/4 "2024-07-04T10:05:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![cetspace25](https://avatars.discourse-cdn.com/v4/letter/c/a8b319/32.png) [@cetspace25](https://community.postman.com/u/cetspace25)\
**Post date:** [July 7, 2024, 5:06am UTC](https://community.postman.com/t/invalid-access-token-using-collection-runner/63339/5 "2024-07-07T05:06:57Z")

</div>

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!

 ![20240706_Postman Error_After Clicking_Use Token and Send_Authorization Tab - Copy](https://us1.discourse-cdn.com/getpostman/original/3X/a/b/abfd9f62b8af645e392caa2435dd8a7039d84c04.png)  
 ![20240706_Postman Error_After Clicking_Use Token_Environment Variables - Copy](https://us1.discourse-cdn.com/getpostman/original/3X/4/6/466f7d6b83bd16c04f74015abab00b2f48b72524.png)  
 ![20240706_Postman Error_After Clicking_Use Token_Global Variables - Copy](https://us1.discourse-cdn.com/getpostman/original/3X/d/3/d3d6d0435cdefc8b37121c28ea0c01281a59b657.png)  
 ![20240706_Postman Error_After Clicking _Use Token_Header Tab - Copy](https://us1.discourse-cdn.com/getpostman/original/3X/a/7/a7e6cbd3bfeb32f0e36468f6a60dddcbe32af86a.png)  
 ![20240706_Postman Error_After Clicking _Use Token_Authorization Tab - Copy](https://us1.discourse-cdn.com/getpostman/original/3X/0/6/068e5edf4b7758aca0ca9b0c0d5f60b6cb1220b7.png)

---

<div class="post-metadata">

**Author:** ![cetspace25](https://avatars.discourse-cdn.com/v4/letter/c/a8b319/32.png) [@cetspace25](https://community.postman.com/u/cetspace25)\
**Post date:** [July 7, 2024, 5:16am UTC](https://community.postman.com/t/invalid-access-token-using-collection-runner/63339/6 "2024-07-07T05:16:05Z")

</div>

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.

 ![20240706_Postman Error_After Clicking_Use Token and Send_Console Log_2 of 2 - Copy](https://us1.discourse-cdn.com/getpostman/original/3X/7/7/7769a5b9b4b2ebbb1295cccfb7f806056348c077.png)  
 ![20240706_Postman Error_After Clicking_Use Token and Send_Console Log_1 of 2 - Copy](https://us1.discourse-cdn.com/getpostman/original/3X/4/d/4d30af3e9b216e5e34cb5ab2b0030497b08031ed.png)

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [July 8, 2024, 10:02am UTC](https://community.postman.com/t/invalid-access-token-using-collection-runner/63339/7 "2024-07-08T10:02:09Z")

</div>

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)](https://docs.precisely.com/docs/sftw/precisely-apis/main/en-us/webhelp/apis/Getting%20Started/generating_an_oauth_token.html)

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](https://us1.discourse-cdn.com/getpostman/original/3X/a/c/ac41d92aedbd87562fe6ae9b6bc71610263fefd9.png)

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](https://us1.discourse-cdn.com/getpostman/original/3X/b/7/b7e2cc8164c49d96abc63fdd77f451b4467dff16.png)

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](https://us1.discourse-cdn.com/getpostman/original/3X/d/6/d60103b718b6b343a2ba85450e7b6dbdff7c6dec.png)

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](https://us1.discourse-cdn.com/getpostman/original/3X/f/e/fef38b9b0de6b487eb9a6899e642d713ee61dbde.png)

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.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [August 7, 2024, 10:02am UTC](https://community.postman.com/t/invalid-access-token-using-collection-runner/63339/8 "2024-08-07T10:02:51Z")

</div>

Closed on August 7, 2024, 10:02am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
