I am working on an Oauth2.0 integration with our NetSuite portal, and I have most everything set up, but I am getting a 500 response invalid when my backend server attempt the token exchange. Can you help me fix this?
First, I will advise that I tested this with POSTMAN using their Oauth 2.0 test, and I still saw the 500 response page not found. It makes me think I am using the wrong URL to authorize or something..?
NetSuite Account ID: [Used my account ID]NetSuite Base Domain: [MY ACCOUNT ID].app.netsuite.com
Problem Description: Both our custom application and when testing using POSTMAN with Oauth 2.0 test, we are consistently receiving an HTTP 500 status code with an HTML response body containing <div class="uir-error-page-message">Page not found</div> when attempting the OAuth 2.0 token exchange POST request to NetSuite's /oauth2/token.nl endpoint. This occurs despite meticulous configuration of the NetSuite Integration Record and extensive troubleshooting, which has ruled out common issues.
Application Architecture:
- Frontend: A static HTML page (
https://[MY PAGE].html) that initiates the OAuth 2.0 Authorization Code Grant flow by redirecting the user to NetSuite's authorize.nl endpoint. - Backend: A Node.js server that:
- Receives the authorization code from the frontend.
- Securely makes a server-to-server POST request to NetSuite's
oauth2/token.nl endpoint to exchange the code for an access token. - Handles sensitive
CLIENT_ID, CLIENT_SECRET, and REDIRECT_URI via environment variables (.env file).
NetSuite Integration Record Configuration (Confirmed):
The NetSuite Integration Record (Monnit_Support_NS or similar name) has been configured with the following settings:
- General:
Name: (APP NAME)State: Enabled (checked)
- Authentication Tab:
Token-based Authentication: CheckedOAuth 2.0: CheckedTBA: issuetoken Endpoint: Checked (Confirmed crucial for token.nl endpoint to be active)Public Key Certificate: Unchecked (Not used for this flow)
- OAuth 2.0 Tab:
- Authorized Token Grant Types:
Authorization Code Grant: Checked (This is the intended flow)Client Credential Grant (Machine To Machine): Unchecked (Confirmed not needed for this flow)User Credentials: Unchecked (Confirmed not needed for this flow)
- Token Flow:
- Redirect URI(s):
- Authorized Scopes:
rest_webservices: Checked- (Other necessary scopes if applicable, e.g.,
suiteanalytics_workbook)
- Client ID & Client Secret:
- Both
CLIENT_ID (Application ID) and CLIENT_SECRET have been:- Copied exactly from NetSuite upon creation.
- Reset in NetSuite, and the new values were meticulously copied and updated in the backend's
.env file. - The Node.js server was restarted to ensure new values were loaded.
- The
CLIENT_ID is used in the frontend's authorization URL and the backend's token exchange. The CLIENT_SECRET is only used by the backend.
NetSuite Role Permissions (Confirmed):
The NetSuite Role associated with the integration (e.g., "COMPANY | Support Administrator") has the following permissions at the Full level:
REST Web Services (under Setup permissions)Log in using OAuth 2.0 Access Tokens (under Setup permissions)
URLs Used by the Application:
- Authorization Endpoint (Frontend GET request to NetSuite):
- Token Endpoint (Backend POST request to NetSuite):
Troubleshooting Steps Performed & Observations:
- Frontend Authorization Flow: Confirmed working correctly, generating a valid authorization
code from NetSuite. - Backend Request Format: Confirmed backend
axios.post uses URLSearchParams and sets Content-Type: application/x-www-form-urlencoded, which is correct. - Error Response Consistency: The
500 HTML "Page not found" is consistently received for all token exchange attempts. - NetSuite Audit Logs: No relevant entries found in the
Login Audit Trail (Setup > Users/Roles > User Management > Login Audit Trail) corresponding to the failed token exchange attempts (even when filtering by backend IP, role, or exact timestamps). This suggests the request might be rejected at a very low level by NetSuite's infrastructure. - Client ID/Secret Reset: Performed a credential reset in NetSuite, meticulously updated the backend
.env, and restarted the server. The 500 error persisted. - Service Status Check: Confirmed NetSuite services are currently active via
https://status.netsuitesuiteprojectspro.com/ (checked [Today's Date, e.g., May 20, 2025]). - Frontend Code Simplification: Created a bare-bones HTML page to initiate authorization; the
500 error during token exchange persisted. - Port Inclusion in Redirect URI: Confirmed
redirect_uri does NOT include the internal backend port (3002), as it is a public URL for browser redirection.
Conclusion: All standard external configurations and troubleshooting steps have been exhausted. The consistent 500 "Page not found" error originating from NetSuite's token.nl endpoint, coupled with the complete absence of corresponding entries in the NetSuite Login Audit Trail, strongly suggests an underlying issue within NetSuite's internal server-side processing for this specific account's OAuth 2.0 integration.