Establishing a Connection
The User and Password properties, under the Authentication section, must be set to valid NetSuite user credentials. In addition, the AccountId must be set to the Id of a company account that can be used by the specified User. The RoleId can be optionally specified to log in the user with limited permissions.
Using OAuth Authentication
OAuth requires the authenticating user to interact with NetSuite using the browser. The provider facilitates this in various ways as described below.
Custom Credentials
You must register an app to obtain the OAuthClientId and OAuthClientSecret.
When to Create a Custom OAuth App
Creating a custom OAuth app is required in all cases in order to connect via OAuth.
Creating a Custom OAuth App
See Creating a Custom OAuth App for information on how to create a custom app.
Custom Credentials
When to Use a Custom OAuth App
Creating a custom OAuth app is required in order to connect via OAuth.
Desktop Authentication with a Custom OAuth App
Follow the steps below to authenticate with the credentials for a custom OAuth app. See Creating a Custom OAuth App.Get and Refresh the OAuth Access Token
After setting the following, you are ready to connect:
- AccountId: Set this to the account id you are connecting to.
- OAuthClientId: Set this to the Consumer Key assigned when you registered your app.
- OAuthClientSecret: Set this to the Consumer Secret assigned when you registered your app.
- CallbackURL: Set this to the redirect URI defined when you registered your app.
- InitiateOAuth: Set this to GETANDREFRESH. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken.
- Extracts the access token from the callback URL and authenticates requests.
- Saves OAuth values in OAuthSettingsLocation to be persisted across connections.
Web Authentication with a Custom OAuth App
When connecting via a Web application, you need to register a custom OAuth app with NetSuite. See Creating a Custom OAuth App. You can then use the provider to get and manage the OAuth token values.
Get an OAuth Access Token
Set the following connection properties to obtain the OAuthAccessToken:
- AccountId: Set this to the account id you are connecting to.
- OAuthClientId: Set this to the Integrator Key assigned when you registered your app.
- OAuthClientSecret: Set this to the Secret Key assigned when you registered your app.
You can then call stored procedures to complete the OAuth exchange:
-
Call the GetOAuthAuthorizationURL stored procedure. Set the AuthMode input to WEB and set the CallbackURL input to the Redirect URI you specified in your app settings.
The stored procedure returns the URL to the OAuth endpoint.
- Open the URL, log in, and authorize the application. You are redirected back to the callback URL.
- Call the GetOAuthAccessToken stored procedure. Set the AuthMode input to WEB. Set the Verifier input to the "code" parameter in the query string of the callback URL.
Refresh the OAuth Access Token
Unlike other sources, NetSuite tokens do not expire. There is no refresh flow.
Headless Machines
Using OAuth on a Headless Machine
To create NetSuite data sources on headless servers or other machines on which the provider cannot open a browser, you need to authenticate from another machine. Authentication is a two-step process.
- Instead of installing the provider on another machine, you can follow the steps below to obtain the OAuthVerifier value. Or, you can install the provider on another machine and transfer the OAuth authentication values, after you authenticate through the usual browser-based flow.
- You can then configure the provider to automatically refresh the access token from the headless machine.
Using the Credentials for a Custom OAuth App
Create a Custom OAuth App
Creating a custom OAuth app is optional in the headless OAuth flow; you can skip creating an app by connecting with the provider's embedded OAuth credentials. You might want to create a custom OAuth app to change the information displayed when users log into NetSuite to grant permissions to the provider.
See Creating a Custom OAuth App for a procedure. You can then follow the procedures below to authenticate and connect to data.
Obtain a Verifier Code
Set the following properties on the headless machine:
- AccountId: Set this to the account id you are connecting to.
- InitiateOAuth: Set this to OFF.
- OAuthClientId: Set this to the Integrator Key assigned when you specified your app.
- OAuthClientSecret: Set this to the Secret Key assigned when you specified your app.
You can then follow the steps below to authenticate from another machine and obtain the OAuthVerifier connection property.
- Call the GetOAuthAuthorizationURL stored procedure with the CallbackURL input parameter set to the exact Redirect URI you specified in your app settings.
- Open the returned URL in a browser. Log in and grant permissions to the provider. You are then redirected to the callback URL, which contains the verifier code.
- Save the value of the verifier code. You will set this in the OAuthVerifier connection property.
On the headless machine, set the following connection properties to obtain the OAuth authentication values:
- AccountId: Set this to the account id you are connecting to.
- OAuthClientId: Set this to the Integrator Key assigned when you specified your app.
- OAuthClientSecret: Set this to the Secret Key assigned when you specified your app.
- OAuthVerifier: Set this to the verifier code.
- OAuthSettingsLocation: Set this to persist the encrypted OAuth authentication values to the specified file.
- InitiateOAuth: Set this to REFRESH.
After the OAuth settings file is generated, set the following properties to connect to data:
- AccountId: Set this to the account id you are connecting to.
- OAuthClientId: Set this to the Integrator Key assigned when you specified your app.
- OAuthClientSecret: Set this to the Secret Key assigned when you specified your app.
- OAuthSettingsLocation: Set this to the file containing the encrypted OAuth authentication values. Make sure this file gives read and write permissions to the provider to enable the automatic refreshing of the access token.
- InitiateOAuth: Set this to REFRESH.
Transfer OAuth Settings
Follow the steps below to install the provider on another machine, authenticate, and then transfer the resulting OAuth values.
On a second machine, install the provider and connect with the following properties set:
- AccountId: Set this to the account id you are connecting to.
- OAuthSettingsLocation: Set this to a writable text file.
- InitiateOAuth: Set this to GETANDREFRESH.
- OAuthClientId: Set this to the Integrator Key assigned when you specified your app.
- OAuthClientSecret: Set this to the Secret Key assigned when you specified your app.
- CallbackURL: Set this to the Redirect URI you specified in your app settings.
Test the connection to authenticate. The resulting authentication values are written, encrypted, to the path specified by OAuthSettingsLocation. Once you have successfully tested the connection, copy the OAuth settings file to your headless machine. On the headless machine, set the following connection properties to connect to data:
- AccountId: Set this to the account id you are connecting to.
- InitiateOAuth: Set this to REFRESH.
- OAuthClientId: Set this to the Integrator Key assigned when you specified your app.
- OAuthClientSecret: Set this to the Secret Key assigned when you specified your app.
- OAuthSettingsLocation: Set this to the path to your OAuth settings file. Make sure this file gives read and write permissions to the provider to enable the automatic refreshing of the access token.
Creating a Custom OAuth App
When to Create a Custom OAuth App
Creating a custom app is required in order to connect.
Follow the steps below to create a custom OAuth app and obtain the connection properties in a specific OAuth authentication flow.
Create a Custom OAuth App: Desktop
Register your NetSuite app on Setup --> Integrations --> Manage Integrations. Make sure to select the checkbox for each of Token-Based Authentication and TBA: Authorization Flow. Then, obtain the following connection properties:
- OAuthClientId: Set this to the Integrator Key assigned when you registered your app.
- OAuthClientSecret: Set this to the Secret Key assigned when you registered your app.
- CallbackURL: Set this to the Callback URL defined when you registered your app such as http://localhost:33333. Note that this must be an exact match including any trailing '/' characters.
Create a Custom OAuth App: Web Apps
- OAuthClientId: Set this to the Integrator Key assigned when you registered your app.
- OAuthClientSecret: Set this to the Secret Key assigned when you registered your app.
Create a Custom OAuth App: Headless Machines
Register your NetSuite app on Setup --> Integrations --> Manage Integrations to obtain the following connection properties:
- OAuthClientId: Set this to the Integrator Key assigned when you registered your app.
- OAuthClientSecret: Set this to the Secret Key assigned when you registered your app.
Creating an Access Token in NetSuite
Create Tokens in the NetSuite UI
An older model that may still be used by admins is to simply create and assign a token directly in the NetSuite UI. Doing this will allow you to bypass the normal steps for generating an OAuth Access Token. This may be desireable if you would like to have more direct control over giving access, although it will always require manual steps to be taken in the UI each time. Instead, follow these steps to create a token in the UI:
- In NetSuite, log in as an administrator role and navigate to Setup --> Company --> Enable Features --> SuiteCloud --> Manage Authentication. Make sure Token-Based Authentication and TBA: Authorization Flow are checked and save changes.
- Navigate to Setup --> Integration --> Manage Integrations.
- Create a new integration and select Token-Based Authentication.
- When the integration is created, the Consumer Key and Consumer Secret displayed will map directly to the OAuthClientId and OAuthClientSecret connection properties. Write these down.
- Create a token role by navigating to Setup --> User/Roles --> Manage Roles and either create a new role or edit an existing role.
- Under Permissions --> Setup, the role must have the User Access Token: Full, Access Token Management: Full, and Web Services: Full permissions.
- Add the role to a user under Lists --> Employees --> Employees. Select to edit an employee and add the new token role under Access --> Roles.
- Navigate to Setup --> User/Roles --> Access Tokens and create a new access token. Select the application name as the integration that was created earlier, and the same user and role that were updated in the previous steps.
- After creating the access token, a Token Id and Token Secret will be displayed. These map directly to the OAuthAccessToken and OAuthAccessTokenSecret. Write these down.
After creating the access token, a connection can now be made using the values obtained from the previous steps. Specify these connection properties at a minimum to connect:
- AccountId specifying the account to connect to.
- OAuthClientId the Consumer Key displayed when the application was created.
- OAuthClientSecret the Consumer Secret displayed when the application was created.
- OAuthAccessToken the Token Id when the access token was created.
- OAuthAccessTokenSecret the Token Secret when the access token was created.
Customizing the SSL Configuration
By default, the provider attempts to negotiate SSL/TLS by checking the server's certificate against the system's trusted certificate store. To specify another certificate, see the SSLServerCert property for the available formats to do so.
Connecting Through a Firewall or Proxy
HTTP Proxies
To connect through the Windows system proxy, you do not need to set any additional connection properties. To connect to other proxies, set ProxyAutoDetect to false.
In addition, to authenticate to an HTTP proxy, set ProxyAuthScheme, ProxyUser, and ProxyPassword, in addition to ProxyServer and ProxyPort.
Other Proxies
Set the following properties:
- To use a proxy-based firewall, set FirewallType, FirewallServer, and FirewallPort.
- To tunnel the connection, set FirewallType to TUNNEL.
- To authenticate, specify FirewallUser and FirewallPassword.
- To authenticate to a SOCKS proxy, additionally set FirewallType to SOCKS5.
Troubleshooting the Connection
To show provider activity from query execution to network traffic, use Logfile and Verbosity. The examples of common connection errors below show how to use these properties to get more context. Contact the support team for help tracing the source of an error or circumventing a performance issue.
- Authentication errors: Typically, recording a Logfile at Verbosity 4 is necessary to get full details on an authentication error.
- Queries time out: A server that takes too long to respond will exceed the provider's client-side timeout. Often, setting the Timeout property to a higher value will avoid a connection error. Another option is to disable the timeout by setting the property to 0. Setting Verbosity to 2 will show where the time is being spent.
- The certificate presented by the server cannot be validated: This error indicates that the provider cannot validate the server's certificate through the chain of trust. If you are using a self-signed certificate, there is only one certificate in the chain.
To resolve this error, you must verify yourself that the certificate can be trusted and specify to the provider that you trust the certificate. One way you can specify that you trust a certificate is to add the certificate to the trusted system store; another is to set SSLServerCert.