GlideEncrypter is not allowed in scoped applications

prasad48
Tera Guru

GlideEncrypter is not allowed in scoped applications.How can i access the function in scoped application?

9 REPLIES 9

This doesn't work when password is in global scope (shared by many apps).

 

 

(function execute() {

    var credential = new GlideRecord('basic_auth_credentials');
	credential.get('name', 'ADO - Pipeline');
    const pat = credential.password.getDecryptedValue();

    var token = GlideStringUtil.base64Encode(':'+pat).toString();
    gs.log("Token: " + token);

})();

 

 

This is the error

abelal_0-1725267227118.png

Works perfectly fine when run in globla scope and I've no idea how to grant it the appropriate scope access because documentation is hard if not impossible to find.

DavidVD
ServiceNow Employee
ServiceNow Employee

The code in the previous reply did not work for me, however, there is a ScopedEncrypter class available for scoped apps (it's a Script Include!).

In my app, I used the code below:

var encryptedSecret = "<your encrypted secret goes here>";
var decryptedSecret = new global.ScopedEncrypter().decrypt(encryptedSecret);
 
 Edit: It looks like this script include is part of a plugin named "IHUB Spoke Util Pack [com.snc.ihub_spoke_util_pack]"

Best post ever

 

Kind Regards

Ashley

Mike322
Tera Contributor

For those that want to know more about this script include but can't just install the plugin, here is some more information:

 

Name: ScopedEncrypter

Description: Utility to be used in integration hub spokes where there is a need to encrypt/decrypt the tokens/keys to be used in the REST request

 

It's a Global Script include that is accessible from other scopes. And the gist is simply that it calls the global new GlideEncrypter function. I'm not sure if I'm allowed by ServiceNow to just copy-paste the code so I suggest creating the script include yourself with this information. 🙂

This is absolutely correct. Thanks David.