How to use API Key Authentication for Outbound REST message ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2022 05:03 AM
I'm using one Outbound REST message. I want to use API Key from Connections & Credentials module as an Authentication type for my REST message. I have API Key in handy. Is it achievable ? I don't want to use basic or oauth authentication type.
- Labels:
-
Event Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2022 05:26 AM
I have seen it using the custom 'Configuration template' in sys_alias. You can install the DevOps application, there I have seen one example of using API key
https://docs.servicenow.com/bundle/paris-devops/page/product/enterprise-dev-ops/concept/dev-ops-landing-page.html
Regards,
Vivek

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2022 08:57 AM
Saurabh,
Yep completely possible,just select API Key as the type when you create the credential. You can then retrieve it using GlideRecord and use GlideEncrypter().decrypt() to return it back to its text form. (If you are in a scoped app you might need to use SecureEncrypter (Part of IH Utils plugin) or create your own scoped SI that can access the global SI.
From there, just put it in as a message header, usually x-apikey
It is even easier if you are using an IntegrationHub REST step in Flow Designer as you can directly use the alias and then pull in the api key from the credential data pill without having to do any retrieval or decryption.
Hope this helps,
Richard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2022 09:31 PM
Hi Richard,
Thanks for sharing this info. I'm able to retrieve API Key in global scope. However I had more concern over scoped application. Can you explain more over SecureEncrypter. global.SecureEncrypter() not working for me. This might help me resolve this issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2022 12:32 AM
Saurabh
SecureEncrypter is part of plugin com.snc.ihub_spoke_util_pack. I am not sure if you need an IH licence to use it....
You could also create an SI of your own in global that is accessible to all scopes and has two methods encrypt and decrypt that then call the same methods in GlideEncrypter leaving you with a way to call GlideEncrypter from any scope (albeit via another SI!).
Hope these help,
Richard