NetSuite suggests to use addCredentialField to save password for a foreign site, and use nlapiRequestURLWithCredentials to send the password to the foreign site to authenticate so that the password is encrypted and not available for a developer to retrieve on NetSuite side. However, I was not able to get it to work.
Here is an example scenario, crafted according to NetSuite document examples:
1. my remote site password is abc123
2. my remote site is https://www.example.com
3. I create an addCredentialField field, and put the value 'abc123', NetSuite only gives me GUID '8ABE039DC0DF4453156805CDD18D1E26' when I try to retrieve the value, which is fine and by design.
4. I call nlapiRequestURLwithCredentials (['8ABE039DC0DF4453156805CDD18D1E26'], 'https://www.example.com/a?pwd={8ABE039DC0DF4453156805CDD18D1E26}')
I expect that remote server sees https://www.example.com/a?pwd=abc123, because I assume NetSuite would substitute the GUID tag with the real password before it makes the call at a bottom layer. The GUID itself means nothing to the foreign site.
However, I found NetSuite sent the GUID tag literal, not the password, https://www.example.com/a?pwd={8ABE039DC0DF4453156805CDD18D1E26}
I am not sure what I was doing wrong, and I logged a case #1693803 with NetSuite, but was not getting problem resolved.
I understand the pwd should not be in the querystring etc., which would be a different discussion. Here we are trying to understand how the addCredentialField substitution works, similar to the example NetSuite documents gave.
I'd appreciate it if somebody can share his/her successful experience with me.
Thanks,
Ray