- 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 01:58 PM
// We use the following code to decrypt 2 way encrypted field. If you have Orchestration Module then you can see the 'basic_auth_credentials' tabel
------------------------------------------------------------------------------------------------------------------------
// Get O365 Admin Credentials
getAdminCredentials();
function getAdminCredentials() {
var gr = new GlideRecord('basic_auth_credentials');
gr.addQuery('name', "O365Admin");
gr.query();
if (gr.next()) {
workflow.scratchpad.adminUserName = String(gr.user_name);
var Encrypter = new GlideEncrypter();
var encrypted = gr.password; // current.<<your field name>>
var decrypted = Encrypter.decrypt(encrypted);
workflow.scratchpad.adminPassword = String(decrypted);
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2017 01:30 PM
Do you have any records in update sources table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2017 01:34 PM
No I don't believe so. This is on our dev instance

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2017 01:38 PM
Got you! Go to data sources and filter on type is JDBC and pick up the sys_id of any one of the record
var gr= new GlideRecord('sys_data_source');
gr.get('11e091bf0a258102005ba7a71b145a8a'); //sys_id of jdbc type data source
var encrypter = new GlideEncrypter();
gs.print(encrypter.decrypt(gr.getValue('jdbc_password')));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2017 01:57 PM