Do you know if it's possible to work with "_API Se...
# suitescript
m
Do you know if it's possible to work with "_API Secrets_" client side? I got it to work on the server's side with
https.createSecureString
. The docs say that method is only applicable to server side scripts, so, how do I securely store API credentials for client side scripts? Thanks.
e
I’m curious. What would be a use-case for doing this? It’s difficult to keep these type of secrets secure when passing them off to use on the client side.
b
you cant use secrets client side
though you can create their predecessor using Form.addCredentialField
it doesnt allow you to use it clientside, but you can create and store credentials for use in other scripts
m
@User I have a button on the invoice transaction that is added to the form with a user event script. That button, when clicked executes a function on a client script. From that client script I make an https request and credentials are used there.
@battk thanks as always, I'll check that out.
a
have the client script call a suitelet, congrats you're server side πŸ™‚
πŸ™ŒπŸΌ 1
☝️ 1
m
@Anthony OConnor I tried doing the Suitelet thing (calling a SL from a client script to get the secret's content) an it's not returning the value in the response to the client script:
Copy code
token = https.createSecureString({input:'{custsecret_my_secret_id}'});
scriptContext.response.write(token);
I noticed secret's contents are not printed in debug logs as well on the server's side (makes sense I suppose). Not sure if this SL + CS passing along can be done or maybe
https.createSecureString
is just meant to use a secret in an https request not to read the value and store it in a variable or whatever.
confused dog 1
a
hmm I wasn't meaning to send the secure string back, I mean move your logic to the suitelet πŸ™‚ sorry I don't know the actual details of what you're doing
m
...ooooooohhhhhhh
I misunderstood the assignment, hehe. I'll explore that, thank you @Anthony OConnor.
πŸ˜‚ 1
Success! That worked. Last question and I'll shut up. Is it possible to create secrets using SuiteScript? I couldn't find any docs on that, it seems they can only be created through the GUI. Am I missing something?
πŸŽ‰ 1
m
@battk, interesting... sorry about the repost. I'll shut up now.