Anyone have an example of retrieving an API Secret...
# suitescript
d
Anyone have an example of retrieving an API Secret from the API Secret Manager with script? I want to store my TBA data but I can't seem to figure out how to load/retrieve the data after I've set it.
b
you use secure strings, which are essentially string templates
d
Setup > Company > Preferences > API Secrets
b
netsuite will fill in the placeholders with the matching secret
d
I don't know how to retrieve that
b
do you know how string templates work
d
yes, but how is that related to this? I don't see how to get this data
keyControl.findKeys
is not related to these keys. And crypto has no load function.
I'm just a bit lost right now
b
the input to https.createSecureString is a string template
where the data used to render the string comes from the api secrets
d
call me blind, i still don't see the connection
b
the examples use a combination of the old credentials guids and the script ids of the api secrets
they both function the same
d
Ah, Concatenate API Secrets with Strings
Let me try this. Thank you!
😢 Still not getting the data. Can I log.debug the data string?
b
its a template that netsuite renders
you dont get access to the rendered output
d
So storing a JSON object as part of the TBA wouldn't work because I can't parse it out separately?
b
not really sure how the json object comes into play
thats not a part of tba
d
I wanted to store the tkey,tsec,ckey,csec, and account number in a json object and then parse it out to call to another account
b
you cant store it in a json object
you can store the placeholders in a json object
api secrets are specifically designed so that you cant read the secrets from script
you are only able to tell suitescript how to use the secrets via securestrings
d
OK. That's great. I love that. But I still can't get it to work. What am I doing wrong?
b
you wont be able to use an external library like OAuth 1.0a
you will have to do your own crypto
that oauth library doesnt use secure strings
d
The OAuth works when I use the string values directly. I want to replace the strings with the secure strings so it's no longer in the code.
b
thats not how api secrets work, they never expose the secrets to the script
d
I have no idea how to use these then. Doesn't seem useful.
b
start simple, do something that doesnt require crypto like just sending a token in a header
graduate to something more complex like basic authentication
then move onto tba
d
I don't think this is going to work for what I was hoping it would do.
I'm calling a Restlet in another account. Without the ability to inject the tokens and consumer values, I can't generate the TBA.
b
not without changing the way you generate the tba header
you wont be able to use the library you are currently using
d
Is there one that will work?
b
none
they would need to use suitescript secure string to do so
d
I'm using CryptoJS as part of the lib
b
still the same answer, you would have to use suitescript related apis
crypto js does not use secure strings