Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How do you set the client id and client secret for an Application Registries OAuth Provider using a script?

dmacias
Giga Contributor

Hi All,

I have an OAuth Provider set up in Application Registries. 

find_real_file.png

Does anyone know how to go about changing the Client ID and Client Secret fields using a script?

I have tried accessing the table through the glide record API but when looking for the Application Registries table name I couldn't find anything.

THANKS!

1 ACCEPTED SOLUTION

Allen Andreas
Tera Patron

Hi,

Can you elaborate a bit more on what you mean by: I couldn't find anything?

Running this simple background script both client id and client secret at a minimum...what did you try?

var gr = new GlideRecord('oauth_entity');
gr.get('sys_id_of_record');
//gs.info("Record client ID is: " + gr.client_id);
//var Encrypter = new GlideEncrypter();
//var encrypted = gr.client_secret;
//var decrypted = Encrypter.decrypt(encrypted);
//gs.info("Record encrypted client secret is: " + encrypted);
//gs.info("Record decrypted client secret is: " + decrypted);
gr.client_id = 'test123';
gr.client_secret.setDisplayValue('test456');
gr.update();

 

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

2 REPLIES 2

Allen Andreas
Tera Patron

Hi,

Can you elaborate a bit more on what you mean by: I couldn't find anything?

Running this simple background script both client id and client secret at a minimum...what did you try?

var gr = new GlideRecord('oauth_entity');
gr.get('sys_id_of_record');
//gs.info("Record client ID is: " + gr.client_id);
//var Encrypter = new GlideEncrypter();
//var encrypted = gr.client_secret;
//var decrypted = Encrypter.decrypt(encrypted);
//gs.info("Record encrypted client secret is: " + encrypted);
//gs.info("Record decrypted client secret is: " + decrypted);
gr.client_id = 'test123';
gr.client_secret.setDisplayValue('test456');
gr.update();

 

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hi Allen,

I can't believe I missed it. Thank you for catching my mistake!