Generate a New OAuth Token for a User

The following sample shows how to generate a new OAuth token for a user. This sample requires the SuiteSignOn feature.

Note:

This sample script uses the require function so that you can copy it into the SuiteScript Debugger and test it. You must use the define function in an entry point script (the script you attach to a script record and deploy). For more information, see SuiteScript 2.x Script Basics and SuiteScript 2.x Script Types.

Important:

The value used in this sample for the suiteSignOnRecordId field is a placeholder. Before using this sample, replace the suiteSignOnRecordId field value with a valid value from your NetSuite account. If you run a script with an invalid value, an error may occur. Additionally, the SuiteSignOn record you reference must be associated with a specific script. You make this association in the SuiteSignOn record’s Connection Points sublist. For help with SuiteSignOn records, see Creating SuiteSignOn Records.

          /**
 * @NApiVersion 2.x
 */

// This script generates a new OAuth oken for a user.
require(['N/sso'], function(sso) {
    function generateSSOToken() {
        var suiteSignOnRecordId = 1;
        var url = sso.generateSuiteSignOnToken(suiteSignOnRecordId);
    }
    generateSSOToken();
}); 

        

General Notices