- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am running the standard checkout demo code from https://developer.paypal.com/integration-builder/. When I click on a payment button (PayPal, or Debit or Credit Card), server.js tries to generate an access token but Node server reports:
Failed to generate Access Token: Error: MISSING_API_CREDENTIALS
at generateAccessToken (file:///C:/Users/Owner/server/server.js:23:13)
This error is the result of missing PAYPAL_CLIENT_ID or PAYPAL_CLIENT_SECRET values. Yet my sandbox credentials are in the process.env file, in the same folder as server.js:
PAYPAL_CLIENT_ID=Aafo...
PAYPAL_CLIENT_SECRET=EOH5...
Any idea what I got wrong or am missing? Thanks!
Solved! Go to Solution.
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Good day@PaulHeft,
I would like to suggest that you double-check the internal website code and verify the path of the .env file that you are importing. Additionally, I recommend adding console logs to check if the values from the .env file are being fetched correctly.
If you still facing an issue, please create a MTS ticket via - https://www.paypal-support.com/s/?language=en_US with the issue description and error details.
Sincerely,
Vaishnavi
PayPal MTS
If this post or any other was helpful, please enrich the community by giving kudos or accepting it as a solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Good day, @PaulHeft,
Thank you for posting to the PayPal community.
Please follow the steps provided in the below detailed guided link to learn about the authentication and how to perform REST API calls :
https://developer.paypal.com/api/rest/authentication/
https://developer.paypal.com/api/rest/postman/
Important: If the token is not utilized within 24 hours, you will be required to generate a new one.
If you still facing the issue, please create an MTS ticket via - https://www.paypal-support.com/s/?language=en_US with the issue description and error details.
Sincerely,
Vaishnavi
PayPal MTS
If this post or any other was helpful, please enrich the community by giving kudos or accepting it as a solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, but I don't think that is my problem. I am using the server.js script supplied by PayPal at https://developer.paypal.com/integration-builder/, so I don't think the problem is in requesting the access token.
...
const { PAYPAL_CLIENT_ID, PAYPAL_CLIENT_SECRET, PORT = 8888 } = process.env;
const base = "https://api-m.sandbox.paypal.com";
const app = express();
// host static files
app.use(express.static("client"));
// parse post params sent in body in json format
app.use(express.json());
/**
* Generate an OAuth 2.0 access token for authenticating with PayPal REST APIs.
* @See https://developer.paypal.com/api/rest/authentication/
*/
const generateAccessToken = async () => {
try {
if (!PAYPAL_CLIENT_ID || !PAYPAL_CLIENT_SECRET) {
throw new Error("MISSING_API_CREDENTIALS");
}
...
My problem starts earlier than the request, at throw new Error() shown above. Somehow the client credentials are not retrieved from the .env file.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Good day@PaulHeft,
I would like to suggest that you double-check the internal website code and verify the path of the .env file that you are importing. Additionally, I recommend adding console logs to check if the values from the .env file are being fetched correctly.
If you still facing an issue, please create a MTS ticket via - https://www.paypal-support.com/s/?language=en_US with the issue description and error details.
Sincerely,
Vaishnavi
PayPal MTS
If this post or any other was helpful, please enrich the community by giving kudos or accepting it as a solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Aha, the problem involves the filename and location of the .env file.
Where the PayPal Integration Builder directions say "Create a .env file", it wasn't clear to me that it had to be in the root directory, above the server directory.
Also, I mistakenly thought the filename should be "process.env", since I saw that in the server.js script. No, it must be ".env"!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- Is it possible to make payments in RON (Romanian Leu) through PayPal? in REST APIs
- Integrate PayPal Checkout, code examples not working in Sandbox Environment
- Does the PayPal Checkout Standard integration support Apple Pay and Google Pay out of the box? in REST APIs
- Card issues open Guest Checkout popup in Braintree Client-side Integration (JS, iOS, Android SDKs)
- Always Sorry Something Went Wrong in Prestashop Checkout or Paypal Official Module in PayPal Payments Standard