Skip to content

Commit c6418e3

Browse files
authored
Sn ap fetchsubscriptionkey (#1999)
* Create getSubscriptionKey.js This BG script will be helpful to fetch the subscription key for any API to view key value if forget, store and update if required for doc purpose This will use GlideEncrypter and Decrypted API * Create Readme.md This BG script will be helpful to fetch the subscription key for any API to view key value if forget, store and update if required for doc purpose This will use GlideEncrypter and Decrypted API to fetch the API keys
1 parent 924a833 commit c6418e3

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This BG script will be helpful to fetch the subscription key for any API to view key value if forget, store and update if required for doc purpose
2+
3+
This will use GlideEncrypter and Decrypter API.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
This BG script will be helpful to fetch the subscription key for any API to view key value if forget, store and update if required for doc purpose
3+
4+
This will use GlideEncrypter and Decrypter API
5+
*/
6+
var gr = new GlideRecord('api_key_credentials');
7+
gr.addQuery('name', ' <ENter your Key Name for ex MSFT subscription Key>'); // Replace with your credential name
8+
gr.query();
9+
if (gr.next()) {
10+
var encryptedApiKey = gr.api_key; // Assuming 'api_key' is the field name
11+
var decryptedApiKey = new GlideEncrypter().decrypt(encryptedApiKey);
12+
gs.info("Decrypted API Key: " + decryptedApiKey);
13+
}

0 commit comments

Comments
 (0)