- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2017 12:09 PM
Below is a class I'm working on. I'm trying to decrypt a Client Secret, but for some reason, the sendPOST function will only return the encrypted value. Any ideas?
var laurensVSTSOauth = Class.create();
laurensVSTSOauth.prototype = {
initialize: function() {
var OAuthClient = new GlideRecord('u_oauth_client');
if (OAuthClient.get('sys_id', 'c09a2bd60fccf6008e2a4b9ce1050e56'))
{
this.client = OAuthClient;
}
},
sendPOST: function(authorizationCode) {
var encrypter = new GlideEncrypter();
var clientSecret;
clientSecret = encrypter.decrypt(this.client.getValue('u_secret'));
return clientSecret;
},
type: 'laurensVSTSOauth'
};
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2017 07:18 AM
I was having the same problem in my instance and found that the field length was the issue, the max length was set by default to 40 which is not large enough to handle the size of the encrypted password, once I changed the max length to 256 and reentered my password. I was able to successful encrypt and decrypt the pasword

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2017 11:16 AM
Yes that is correct.
On Thu, Feb 16, 2017 at 13:14 lmcmanamon <community-no-reply@servicenow.com>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2017 12:50 PM
Hey Lauren,
I am unable to replicate this on my end. I was able to get the decrypted value of a scoped app table in global scope. Can you try the same thing on a global table as well. Pick any user record and run this in the background script and see if it gives you the decrypted value
var gr= new GlideRecord('sys_user');
gr.get('sys_id goes here');
var encrypter = new GlideEncrypter();
gs.print(encrypter.decrypt(gr.getValue('user_password')));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2017 01:11 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2017 01:19 PM
Sorry my bad, user_password field on the user table is 1 way encrypted. That is why you are seeing this message. It will work with 2 way encrypted fields.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2017 01:27 PM
Do you have an example of a 2-way encrypted field that I could try?