This repository contains a PowerShell script for authenticating and accessing the Oracle NetSuite REST API using OAuth 2.0 Machine 2 Machine Client Credentials flow. The script demonstrates how to generate a JWT, sign it, obtain an access token, and make authenticated API requests to NetSuite.
- PowerShell 6 (Core) or later
(Windows PowerShell is not supported; use PowerShell Core) - An Oracle NetSuite account with API access enabled
- OAuth 2.0 Client Credentials integration set up in NetSuite
- Access to your integration's certificate/private key in PEM format
-
Clone this repository or download the script:
git clone https://github.com/jascomp/oracle-netsuite-rest-api-powershell.git
-
Edit the script:
Openoracle-netsuite-rest-api.ps1and update the following placeholders:[Certificate ID from OAuth 2.0 Client Credentials Setup][Client ID provided during Integration Setup]<accountID><File path to public.pem>- Any other relevant fields in the script
-
Run the script:
./oracle-netsuite-rest-api.ps1
-
Expected Output:
If configured correctly, the script will:- Generate and sign a JWT
- Obtain an OAuth access token from the NetSuite token endpoint
- Use the token to make a sample GET request (e.g., retrieving a customer record)
- Print the API response in JSON format
- Oracle has phased out support for PKCSv1.5 for RSA signatures. You must now use PSS. If you continue to use PKCSv1.5 the service will return
invalid_grant.
For a full explanation of the process and script walkthrough, see the accompanying blog post:
Accessing Oracle NetSuite REST API Using PowerShell