Bibek Shrestha
02/15/2024, 5:42 PMClay Roper
02/15/2024, 6:01 PMBibek Shrestha
02/15/2024, 6:06 PMsecret
to password field here, but this is in the UI.
I need to achieve this programmatically.Bibek Shrestha
02/15/2024, 6:08 PMIsrael Gonzalez
02/15/2024, 7:52 PMbattk
02/15/2024, 8:55 PMbattk
02/15/2024, 8:56 PMbattk
02/15/2024, 8:57 PMBibek Shrestha
02/15/2024, 9:03 PMBibek Shrestha
04/15/2024, 8:11 PMform.addCredentialField
api called, like this:
const form = context.form;
const credField = form.addCredentialField({...});
I’m not sure how to add the secret to this credField. I tried with defaultValue:
credField.defaultValue = someSecret;
But I get the same secret if I log the form in my restlet, and not the GUID which I was hoping for.
I didn’t find any other way to input a value to the field.
Any suggestions?battk
04/15/2024, 8:13 PMbattk
04/15/2024, 8:14 PMbattk
04/15/2024, 8:14 PMBibek Shrestha
04/15/2024, 8:36 PMBibek Shrestha
05/06/2024, 2:46 PMbattk
05/06/2024, 4:27 PMBibek Shrestha
05/06/2024, 5:08 PMkey
from GUID, I would have to use one of the API secrets
APIs anyways, right?Bibek Shrestha
05/06/2024, 5:10 PMGUID
, I could run this to get the `secretKey`:
const secretKey = crypto.createSecretKey({
guid: guid,
encoding: encode.Encoding.UTF_8
});
What I’m confused here is, do I have to run this during the storing process or just when retrieving the key?battk
05/06/2024, 5:10 PMbattk
05/06/2024, 5:12 PMBibek Shrestha
05/06/2024, 5:14 PMBibek Shrestha
05/06/2024, 5:15 PMbattk
05/06/2024, 5:16 PMBibek Shrestha
05/06/2024, 5:22 PMform.addCredentialField
field or do I need to convert that to something else?
I need it for long term use, meaning this doesn’t change without manual step.battk
05/06/2024, 5:23 PMbattk
05/06/2024, 5:23 PMBibek Shrestha
05/16/2024, 9:26 PMform.addCredentialField
like below to create GUID of the clientSecret.
const secretCredField = form.addCredentialField({
id: "custpage_client_secret_guid",
label: "Client Secret",
restrictToDomains: ["example.com"],
restrictToScriptIds: ["customscript_secrets_ue"],
restrictToCurrentUser: false,
});
I store this clientSecret GUID along with host and clientId in a custom record.
Now when NetSuite needs to make a call to that external system, I need to create a HTTPS Authorization
header with above info using basic authentication scheme like below.
Basic base64Encode(clientId:clientSecret)
Now my question is, which API should I use to retrieve the original clientSecret from the GUID? My options are https.createSecretKey
and https.createSecureString
. I believe I should use the second one but please tell me if I’m wrong.
And what encoding do I use (default is UTF_8)? I didn’t use any encoding when creating GUID.
clientSecret = https.createSecureString({
input: clientSecretGuid,
inputEncoding: https.Encoding.UTF_8
});
Again, this returns an https.SecureString
object. How do I extract actual clientSecret string from it?
I even tried below and prefix Basic
after but it doesn’t seem to work too.
const base64Encoded = https.createSecureString({
input: `${clientId}:${clientSecretGuid}`,
inputEncoding: https.Encoding.BASE_64,
});
Not being able to log the encoded strings, even during dev, is pretty frustrating 😄
Any help here would be appreciated. TIAbattk
05/16/2024, 9:39 PMbattk
05/16/2024, 9:39 PMbattk
05/16/2024, 9:40 PMbattk
05/16/2024, 9:41 PMbattk
05/16/2024, 9:41 PMbattk
05/16/2024, 9:41 PMbattk
05/16/2024, 9:41 PMbattk
05/16/2024, 9:43 PMbattk
05/16/2024, 9:46 PMBibek Shrestha
05/16/2024, 9:47 PMUTF_8
Bibek Shrestha
05/16/2024, 9:49 PMhttps.SecureString
object that the https.createSecureString
returns?battk
05/16/2024, 9:49 PMbattk
05/16/2024, 9:50 PMbattk
05/16/2024, 9:51 PMbattk
05/16/2024, 9:52 PMbattk
05/16/2024, 9:53 PMbattk
05/16/2024, 9:54 PMbattk
05/16/2024, 9:55 PMBibek Shrestha
05/16/2024, 10:04 PMBibek Shrestha
05/16/2024, 10:05 PMbattk
05/16/2024, 10:06 PMbattk
05/16/2024, 10:07 PM