I am having trouble referencing API Secrets via su...
# suitescript
k
I am having trouble referencing API Secrets via suitescript using the secret id generated with the new API secrets management feature in 2021.1. How are these resolved in script?
w
How are you trying to use it? My understanding is that you can only use the secrets with other NS-apis that can consume them. You can never get the actual key/password as a string in your code.
k
I may be misunderstanding the API secrets but I was hoping to resolve them in my script in the https method for a 3rd party API call. I am able to do this with the addCredentialsField method to create a secret hash that resolves via https.SecureString (as seen in Marty Zigman's article https://blog.prolecto.com/2014/09/17/how-to-use-netsuites-nlapirequesturlwithcredentials-api/). It seemed as though the new feature would allow me to do this in the same way, but with better management. The code sample in the help docs Account Administration > Authentication > Secrets Management > Code Sample shows how to reference a secret by using its script ID, but it doesn't make any sense to me.
I figured it out - I had a syntax issue. It does resolve in the same way! Thanks Watz for taking the time to respond to this.
const secureToken = https.createSecureString({
  
input: '{' + 'custsecret_api_key' + '}'
});
the secret id can be referenced with "{" & "}" in the input of createSecureString. Then, it can be used as a variable no need to use the
Copy code
credentials
parameter in the https method.
👍 1