NetSuite OAuth 2.0 Authentication for SuiteCloud Development Framework (SDF)

NetSuite OAuth 2.0 Authentication for SuiteCloud Development Framework (SDF)

With the release of SuiteCloud SDK version 2024.2 (or 2.0.0 for @oracle/suitecloud-cli), NetSuite introduces OAuth 2.0 as the new standard for authentication in the SuiteCloud Development Framework (SDF). This update marks a significant shift from the previous methods of Browser-Based and Token-Based Authentication (TBA).

Transition from TBA to OAuth 2.0

While Browser-Based authentication remains supported for user interactions, Token-Based Authentication (TBA) is now deprecated. OAuth 2.0 is required for all SDF connections, necessitating new authentication IDs. The transition to OAuth 2.0 involves using a new command format:

  • Old Command: suitecloud account:savetoken --account 123456 --authid my-ci --tokenid XXX --tokensecret XXX
  • New Command: suitecloud account:setup:ci --account 123456 --authid my-ci --certificateid XXXX --privatekeypath ~/pathtomykey/private-key.pem

Setting Up OAuth 2.0 Authentication

To set up OAuth 2.0 for your SDF project, follow these steps:

Step 1: Create an SSL Certificate

Generate an SSL certificate using the openssl tool to create both a public and a private key. The public key will be uploaded to NetSuite, while the private key remains confidential:

bash
Copy code
openssl req -new -x509 -newkey rsa:4096 -keyout private.pem -out public.pem -nodes

The public key is used for the --certificateid argument, and the private key is specified with the --privatekeypath argument.

Step 2: Upload the Public Key to NetSuite

Navigate to Setup > Integration > OAuth Client Credentials (M2M) Setup in NetSuite:

  1. Click CREATE NEW.
  2. Select the Entity (Employee) and Role for the SDF profile.
  3. Choose SuiteCloud Development Integration as the Application.
  4. Upload the public certificate created in Step 1.

NetSuite will generate a Certificate ID, which is used in the --certificateid argument of the new command.

Step 3: Configure SuiteCloud with OAuth 2.0

Within your SuiteCloud project folder, run the following command:

bash
Copy code
suitecloud account:setup:ci --account <Your Account ID> --authid <Your Auth ID> --certificateid <Your Certificate ID> --privatekeypath <Path to Your Private Key>

Replace <Your Account ID>, <Your Auth ID>, <Your Certificate ID>, and <Path to Your Private Key> with the appropriate values.

If prompted about old credentials, delete the existing credentials file at ~/.suitecloud-sdk/credentials and run the command again. This action will clear previous authentication IDs but is necessary for compatibility with the new version.

Conclusion

The shift to OAuth 2.0 authentication in NetSuite’s SuiteCloud Development Framework enhances security and streamlines the integration process. By following these steps, you can successfully set up and utilize OAuth 2.0 for your SDF projects, ensuring a secure and modern authentication approach.

Leave a comment

Your email address will not be published. Required fields are marked *