Has anyone ever used NS API Secrets from Suitescri...
# suitescript
e
Has anyone ever used NS API Secrets from Suitescript? The Docs show this: https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_160216636819.html
Copy code
require(['N/file', 'N/sftp', 'N/certificateControl'], (file, sftp, certificateControl) => {
    var connection = sftp.createConnection({
        username: 'sftpuser',
        secret: 'custsecret1',​ // This is the reference to the script ID.
        url: '172.25.182.109',
        port: 22,
        directory: 'certificates'
    });
  
    try {
        var cert = certificateControl.createCertificate({
            name: 'NAAcert2020',
            file: connection.download({
                directory: '2020',
                filename: 'NAA_cert.pfx'
            }),
            password: 'custsecret2'​ ​ // This is the reference to the script ID.
        });
        var certId = cert.save();
    } catch (e) {
        log.error(e.message);
    }
});​
But I don't understand any of these values except for my secret ID. Username? url, port directory etc .... ? Anyone have any idea? thanks!
e
What are you trying to accomplish with a Secret?
e
store a value. Any value. But I need to call it from code
e
e
Copy code
let apiKey = https.createSecureString({
            input: '{CUSTSECRET_SOME_INTEGRATION}'
        });
when i do this, i just get {}
not the value
e
If you're trying to log the value, you won't see it
e
When i log out my full API auth headers
Copy code
{
   Authorization: "https.SecureString:https.SecureString"
}
Is it really there? because the API calls are failing when i do it this way. They pass when putting the value directly in there
e
I am currently using one successfully like this in an active integration project:
Copy code
let response = https.delete({
        url: requestUrl,
        headers: {
          'Authorization': https.createSecureString({ input: 'Bearer {custsecret_airtable}' })
        }
      })
There's no other code necessary to reference the secret
e
Thanks! works
1