netsuite-oauth-client
v1.0.7
Published
NetSuite OAuth 1.0 client library for Node.js with TypeScript support
Maintainers
Readme
NetSuite OAuth Client 🚀
Simple and easy-to-use NetSuite OAuth library for Node.js applications. No more complex OAuth setup - just plug in your credentials and start making API calls!
Why Use This Library?
- 🎯 Simple Setup - Just 3 lines of code to get started
- 🔐 Secure - Handles all OAuth 1.0 complexity for you
- 📝 TypeScript Ready - Full type support out of the box
- 🛠️ Works Everywhere - Use with any HTTP client (axios, fetch, etc.)
- ⚡ Zero Dependencies - Lightweight and fast
Installation
npm install netsuite-oauth-clientQuick Start (3 Steps!)
Step 1: Install and Import
const { NetSuiteOAuthClient } = require("netsuite-oauth-client");
// Or with ES6/TypeScript
import { NetSuiteOAuthClient } from "netsuite-oauth-client";Step 2: Create Client with Your Credentials
const client = new NetSuiteOAuthClient({
accountid: "your_account_id",
consumerkey: "your_consumer_key",
consumersecret: "your_consumer_secret",
tokenkey: "your_token_key",
tokensecret: "your_token_secret",
apibaseurl:
"https://your-account.suitetalk.api.netsuite.com/services/rest/query/v1/suiteql",
});Step 3: Real-World Examples
📋 Get All Customers
import axios from "axios";
import { NetSuiteOAuthClient } from "netsuite-oauth-client";
const getOauthClient = new NetSuiteOAuthClient({
// Your credentials here
});
async function getAllCustomers() {
try {
const requestOptions = client.createRequestOptions({
url: "https://your-account.suitetalk.api.netsuite.com/services/rest/query/v1/suiteql",
method: "POST",
data: {
q: "query",
},
headers: {
"Content-Type": "application/json",
Accept: "application/json",
Authorization: getOauthClient,
},
});
const response = await axios(requestOptions);
console.log("Customers:", response.data);
return response.data;
} catch (error) {
console.error("Error:", error.message);
}
}
getAllCustomers();Getting Your NetSuite Credentials
Step 1: Create Integration Record
- Login to NetSuite
- Go to Setup → Integration → New
- Fill in:
- Name: Your App Name
- State: Enabled
- Token-Based Authentication: ✅ Checked
- Save and copy the Consumer Key and Consumer Secret
Step 2: Create Access Token
- Go to Setup → Users/Roles → Access Tokens → New
- Select your integration
- Select user and role
- Save and copy the Token Key and Token Secret
Step 3: Find Your Account ID
- Look at your NetSuite URL:
https://[ACCOUNT-ID].app.netsuite.com - Or go to Setup → Company → Company Information
Step 4: Build API URL
https://[ACCOUNT-ID].suitetalk.api.netsuite.com/services/rest/platform/v1Troubleshooting
❌ "Invalid signature" error
- Check your consumer secret and token secret
- Verify your account ID is correct
- Ensure system time is accurate
❌ "Invalid token" error
- Verify token key and token secret
- Check if token is expired or disabled
- Ensure user has proper role permissions
❌ "Access denied" error
- Check user role permissions
- Verify integration record is enabled
- Ensure token-based authentication is enabled
❌ "Invalid URL" error
- Check your account ID in the API base URL
- Verify the endpoint path is correct
Need Help?
- 📖 Documentation: Check the examples above
- 🐛 Issues: GitHub Issues
- 💬 Questions: GitHub Discussions
- 📧 Email: [email protected]
What's Next?
- ⭐ Star this repo if it helped you!
- 🔄 Share with your team
- 🐛 Report issues you find
- 💡 Suggest features you need
Made with ❤️ for the NetSuite developer community
