```const getGCPBearerToken = () => { const gui...
# suitescript
c
Copy code
const getGCPBearerToken = () => {
    const guid = 'custsecretgcp_jwt_service';
    const secretKey = crypto.createSecretKey({
        guid: guid,
        encoding: crypto.Encoding.UTF_8
    });
    return secretKey
}
Is this the correct way to get a value from the NetSuite API secrets? I don’t think it’s possible to log the returned key so it’s very hard to see why I’m getting a HTTP 401 when using the returned value as bearer token. Replacing this code with the token (as a string) works, that means the issue is with the API secret.
Copy code
"headers": {
      "Content-Type": "application/json",
      "Authorization": "Bearer crypto.SecretKey"
    },
FYI: my whole approach was wrong. I should have been using https.createSecureString to grab the API secret.
👍 1
h
You could use the API secrets to create secretKey and use that to encrypt and decrypt the information. Using crypto.createCipher and crypto.createDecipher