Older version of SCA have email authentication which will be deprecated. You will not be able to proceed with email authentication for fetching, creating and deploying extension or theme or source code. For that you need to enable token-based authentication (TBA) to your older version of SCA. Latest version of SCA have TBA as inbuilt. For older versions, we need to manually modify some files as provided below in order to enable TBA.
Below steps apply to SuiteCommerce Advanced, Denali, Mont Blanc, Vinson, Elbrus, Kilimanjaro, Aconcagua, 2018.2, 2019.1, 2019.2, 2020.1, 2020.2 versions.
1. Modify the index.js File for Gulp Deployments
- File Location: In your SCA source directory, navigate to and open: …/gulp/ns-deploy/index.js
- Modification 1:
- Find this line:
, doUntilGetRoles
- Replace it with these lines:
, ui.selectToken , net.authorize
- Modification 2:
- Find these lines:
async.apply(ui.roles, deploy), net.targetFolder,
- Replace them with this line:
async.apply(net.targetFolder, deploy),
- Modification 3:
- Find these lines:
async.apply(ui.roles, deploy), net.getWebsitesAndDomains,
- Replace them with this line:
async.apply(net.getWebsitesAndDomains, deploy),
- Modification 4:
- Find these lines:
, ui.email , ui.password , net.roles , ui.roles
- Replace them with these lines:
, ui.selectToken , net.authorize
2. Modify the
- File Location: In your SCA source directory, navigate to and open: …/ns_npm_repository/suitetalk4node/src/tool.js
- Note: In SCA versions 2018.2 and 2019.1, ns_npm_repository is at the top level. In versions 2019.2 through 2020.2, it resides within the Commons directory.
- Modification:
- Find this line:
nsVersion: '2015_1'
- Replace it with this line:
nsVersion: '2020_2'
3. Modify the
- File Location: In your SCA source directory, navigate to and open: …/ns_npm_repository/suitetalk4node/src/templates/getDataCenterUrls.tpl
- Note: Check the location of ns_npm_repository based on your SCA version as mentioned in Step 2.
- Modification:
- Find this line:
<nsmessages:account>{{account}}</nsmessages:account>
- Replace it with this line:
<nsmessages:account>{{credentials.account}}</nsmessages:account>
4. Modify the
- File Location: In your SCA source directory, navigate to and open: …/ns_npm_repository/suitetalk4node/src/template.js
- Note: Check the location of ns_npm_repository based on your SCA version as mentioned in Step 2.
- Modification 1 (Add Dependency):
- Find these lines:
var Handlebars = require('handlebars')
, fs = require('fs')
- Replace them with these lines (adding OAuth1):
var Handlebars = require('handlebars')
, OAuth1 = require('oauth1').OAuth1
, fs = require('fs')
- Modification 2 (Replace
- Find the existing _template method:
, _template: function(file_name, params)
{
this._initTemplateContext(params);
var fileName = path.join(__dirname, '/templates/', file_name);
var template = Handlebars.compile(fs.readFileSync(fileName, {encoding: 'utf8'}).toString());
return template(params);
}
- Replace it entirely with the following code:
, _template: function(file_name, params)
{
var self = this;
var oauth1 = new OAuth1(this.credentials);
return oauth1.soapAuthorize(this.credentials.authID).then(function(credentials) {
self._initTemplateContext(params);
params.credentials = params.credentials || {};
params.credentials.vm = self.credentials.vm;
params.credentials.molecule = self.credentials.molecule;
params.credentials.authID = self.credentials.authID;
params.credentials.token = credentials.token || self.credentials.token;
params.credentials.signature = credentials.signature || self.credentials.signature;
params.credentials.nonce = credentials.nonce || self.credentials.nonce;
params.credentials.timestamp = credentials.timestamp || self.credentials.timestamp;
params.credentials.account = credentials.account || self.credentials.account;
params.credentials.consumerKey = credentials.consumerKey || self.credentials.consumerKey;
var fileName = path.join(__dirname, '/templates/', file_name);
var template = Handlebars.compile(fs.readFileSync(fileName, {encoding: 'utf8'}).toString());
return template(params);
});
}
5. Modify the
- File Location: In your SCA source directory, navigate to and open: …/ns_npm_repository/suitetalk4node/src/communications.js
- Note: Check the location of ns_npm_repository based on your SCA version as mentioned in Step 2.
- Modification 1 (Update
- Find this line within the _request method definition:
, _request: function(action, payload, cb)
{
- Replace it with this code (adding default callback):
, _request: function(action, payload, cb)
{
cb = cb || function(){};
- Modification 2 (Replace
- Find the entire existing __request method (starts with , __request: function(action, payload, cb)).
- Replace it entirely with the following code:
, __request: function(action, payload, cb) {
const self = this;
cb = cb || function() {};
const datacenterDomain =
(self.dataCenterDomains && self.dataCenterDomains.webservices) ||
this.getDefaultWebServiceUrl();
const args = require('yargs').argv;
if (args.proxy) {
request = request.defaults({ proxy: args.proxy });
}
return payload.then(function(payloadResult) {
return new Promise(function(resolve, reject) {
self.getQueue().add(self, function(taskDone) {
const req = request(
{
method: 'POST',
uri: datacenterDomain + "/services/NetSuitePort_" + self.nsVersion,
headers: {
'User-Agent': self.credentials.user_agent || 'Node-SOAP/0.0.1',
Accept:
'text/html,application/xhtml+xml,application/xml,text/xml;q=0.9,*/*;q=0.8',
'Accept-Encoding': 'none',
'Accept-Charset': 'utf-8',
Connection: 'close',
'Content-Type': 'text/xml; charset=utf-8',
SOAPAction: '"' + action + '"'
}
},
function(err, response) {
if (err) {
return cb(err);
}
xml2js.parseString(response.body, self._xml2jsOptions, function(
err,
result
) {
if (err) {
reject(err);
return cb(err);
}
const soap_body = result.Envelope.Body[0];
if (soap_body && soap_body.Fault) {
reject(new Error(soap_body.Fault[0].faultstring[0]));
return cb(new Error(soap_body.Fault[0].faultstring[0]));
}
resolve(soap_body);
taskDone();
cb(null, soap_body, result);
});
}
);
req.end(payloadResult);
});
});
});
}
6. Modify the
- File Location: In your SCA source directory, navigate to and open: …/ns_npm_repository/suitetalk4node/src/templates/_passport.tpl
- Note: Check the location of ns_npm_repository based on your SCA version as mentioned in Step 2.
- Modification:
- Find these lines (the existing passport template):
<nsmessages:passport>
{{#if credentials.email}}<nscore:email>{{credentials.email}}</nscore:email>{{/if}}
{{#if credentials.password}}<nscore:password>{{credentials.password}}</nscore:password>{{/if}}
{{#if credentials.account}}<nscore:account>{{credentials.account}}</nscore:account>{{/if}}
{{#if credentials.roleId}}<nscore:role internalId="{{credentials.roleId}}"/>{{/if}}
</nsmessages:passport>
- Replace them entirely with the following code (the new token passport template):
<ns:tokenPassport actor="http://schemas.xmlsoap.org/soap/actor/next" mustUnderstand="0"
xmlns:ns="urn:messages_2020_1.platform.webservices.netsuite.com">
{{#if credentials.account}}<ns:account>{{credentials.account}}</ns:account>{{/if}}
{{#if credentials.consumerKey}}<ns:consumerKey>{{credentials.consumerKey}}</ns:consumerKey>{{/if}}
{{#if credentials.token}}<ns:token>{{credentials.token}}</ns:token>{{/if}}
{{#if credentials.nonce}}<ns:nonce>{{credentials.nonce}}</ns:nonce>{{/if}}
{{#if credentials.timestamp}}<ns:timestamp>{{credentials.timestamp}}</ns:timestamp>{{/if}}
{{#if credentials.signature}}<ns:signature algorithm="HMAC_SHA256">{{credentials.signature}}</ns:signature>{{/if}}
</ns:tokenPassport>
7. Modify
- File Location: In the top-level directory of your SCA source code, open the package.json file.
- Modification:
- Locate the dependencies section.
- Add the following line within the dependencies object:
"oauth1": "file:./ns_npm_repository/oauth1",
- Example excerpt after adding:
"dependencies": {
"oauth1": "file:./ns_npm_repository/oauth1",
"ansi-colors": "2.0.1",
"archiver": "2.1.1",
"async": "2.6.1",
// ... other dependencies
},
8. Create the
- Action: In your SCA source directory, navigate into the ns_npm_repository folder.
- Note: Remember the location difference based on SCA version (Step 2).
- Create a new directory named oauth1. The path should look like: …/ns_npm_repository/oauth1
- Action: Copy all source files from the oauth1 folder found within the patch zip file (TBApatch-aconcagua–18.2–19.2–20.1–20.2.zip) into the new …/ns_npm_repository/oauth1 directory you just created.
9. Replace Gulp Files
- Action: Locate the following files within the patch zip file (TBApatch-aconcagua–18.2–19.2–20.1–20.2.zip).
- Replace the corresponding files in your SCA source directory with these patched versions:
- …/gulp/ns-deploy/net.js
- …/gulp/ns-deploy/ui.js
10. Run NPM Command for
- Action: Open your terminal or command prompt.
- Navigate to the top-level directory of your SuiteCommerce Advanced source code.
- Run the following command:
npm i oauth1 suitetalk
Reference: Enable Token-Based Authentication (Aconcagua and Later Versions)