Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

How to perform REST API + flow designer with external credential store credential via midserver

VaranAwesomenow
Mega Sage

I am trying to implement a solution where I need to make a REST API call using midserver.

Credentials are stored on external credential store. I need to use External credential storage app from ServiceNow and fetch the credentials and use that in the REST API Call.

Credential type = basic authentication.

Setup done -> A working credential resolver jar on midserver.

It works for windows authentication

Sample properties file

disco_user.windows.user=.\\Administrator
disco_user.windows.pswd=?WDV;@6MjVbXytM2WiOu(dEFqZ-hhwLD
rest_user.basic.user=admin_anil
rest_user.basic.pswd=MyAXXXXnP@55w0rd
 
 

It works for windows credentials

VaranAwesomenow_0-1682303907444.png

 

When I use the same in flow designer REST API action with another credential of type basic auth, it doesnt work

VaranAwesomenow_4-1682304074978.png

 

VaranAwesomenow_1-1682303943634.png

Midserver logs :

2023-04-24T02:31:34.899+0000 INFO (LogStatusMonitor.60) [LogStatusMonitor:50] 2023-04-24T02:31:34.897Z, stats threads: 93, memory max: 910.0mb, allocated: 270.0mb, used: 91.0mb, standard.queued: 0 probes, standard.processing: 0 probes, expedited.queued: 0 probes, expedited.processing: 0 probes, interactive.queued: 0 probes, interactive.processing: 0 probes
2023-04-24T02:31:56.805+0000 INFO (ECCQueueMonitor.1) [ECCQueueMonitor:384] Received message with timestamp: 2023-04-24 02:31:56. Existing Query window is : 2023-04-24 00:31:02, Updated the query window to: 2023-04-24 00:31:56
2023-04-24T02:31:56.805+0000 INFO (ECCQueueMonitor.1) [FileReadWrite:66] Time being written to the file : 1682296316000
2023-04-24T02:31:56.821+0000 INFO (Worker-Expedited:IPaaSActionProbe-edbe8acf07562d54b965f7208c1ed09d) [AWorker:128] Worker starting: IPaaSActionProbe source: 51be8acfca562d541ecfd5cf34bca21c
2023-04-24T02:31:58.154+0000 INFO (Worker-Expedited:IPaaSActionProbe-edbe8acf07562d54b965f7208c1ed09d) [AbstractHttpOperation:525] contextId=51be8acfca562d541ecfd5cf34bca21c IPaaSActionProbe | Credentials sys_id: 7e504a4707d22d54b965f7208c1ed061
2023-04-24T02:31:59.783+0000 INFO (Worker-Expedited:IPaaSActionProbe-edbe8acf07562d54b965f7208c1ed09d) [ECCSender:208] Enqueuing: C:\ServiceNow\ServiceNow MID Server varanmidaws\agent\work\monitors\ECCSender\output_1\ecc_queue.edbe8acf07562d54b965f7208c1ed09d.xml
2023-04-24T02:31:59.784+0000 INFO (Worker-Expedited:IPaaSActionProbe-edbe8acf07562d54b965f7208c1ed09d) [AWorker:136] Worker completed: IPaaSActionProbe source: 51be8acfca562d541ecfd5cf34bca21c time: 0:00:02.831
2023-04-24T02:32:00.100+0000 INFO (ECCSender.1) [ECCSenderCache:349] Sending ecc_queue.edbe8acf07562d54b965f7208c1ed09d.xml
2023-04-24T02:32:33.527+0000 INFO (LogStatusMonitor.60) [LogStatusMonitor:50] 2023-04-24T02:32:33.527Z, stats threads: 93, memory max: 910.0mb, allocated: 303.0mb, used: 89.0mb, standard.queued: 0 probes, standard.processing: 0 probes, expedited.queued: 0 probes, expedited.processing: 0 probes, interactive.queued: 0 probes, interactive.processing: 0 probes
2023-04-24T02:33:33.502+0000 INFO (LogStatusMonitor.60) [LogStatusMonitor:50] 2023-04-24T02:33:33.502Z, stats threads: 93, memory max: 910.0mb, allocated: 270.0mb, used: 89.0mb, standard.queued: 0 probes, standard.processing: 0 probes, expedited.queued: 0 probes, expedited.processing: 0 probes, interactive.queued: 0 probes, interactive.processing: 0 probes

 

If I change the credential type of basic auth to user name password instead of external credential store approach it works

VaranAwesomenow_2-1682303979484.png

 

VaranAwesomenow_3-1682304037620.png

Midserver logs

2023-04-24T02:40:10.596+0000 INFO (ECCQueueMonitor.1) [ECCQueueMonitor:384] Received message with timestamp: 2023-04-24 02:40:10. Existing Query window is : 2023-04-24 00:39:53, Updated the query window to: 2023-04-24 00:40:10
2023-04-24T02:40:10.596+0000 INFO (Worker-Interactive:SystemCommand-1a905ecb07562d54b965f7208c1ed06b) [AWorker:128] Worker starting: SystemCommand source: credentials_reload
2023-04-24T02:40:10.596+0000 INFO (Worker-Interactive:SystemCommand-1a905ecb07562d54b965f7208c1ed06b) [Instance:934] Running system command: credentials_reload
2023-04-24T02:40:10.612+0000 INFO (ECCQueueMonitor.1) [FileReadWrite:66] Time being written to the file : 1682296810000
2023-04-24T02:40:11.893+0000 INFO (Worker-Interactive:SystemCommand-1a905ecb07562d54b965f7208c1ed06b) [StandardCredentialsProvider:396] 18 Credentials from instance loaded
2023-04-24T02:40:11.908+0000 INFO (Worker-Interactive:SystemCommand-1a905ecb07562d54b965f7208c1ed06b) [MIDCredentialsConfigProvider$MyEventListener:83] com.service_now.mid.creds.provider.standard.StandardCredentialsProvider reloaded
2023-04-24T02:40:12.892+0000 INFO (Worker-Interactive:SystemCommand-1a905ecb07562d54b965f7208c1ed06b) [StandardCredentialsProvider:396] 18 Credentials from instance loaded
2023-04-24T02:40:12.892+0000 INFO (Worker-Interactive:SystemCommand-1a905ecb07562d54b965f7208c1ed06b) [MIDCredentialsConfigProvider$MyEventListener:83] com.service_now.mid.creds.provider.standard.StandardCredentialsProvider reloaded
2023-04-24T02:40:12.971+0000 INFO (Worker-Interactive:SystemCommand-1a905ecb07562d54b965f7208c1ed06b) [ECCSender:208] Enqueuing: C:\ServiceNow\ServiceNow MID Server varanmidaws\agent\work\monitors\ECCSender\output_0\ecc_queue.1a905ecb07562d54b965f7208c1ed06b.xml
2023-04-24T02:40:13.002+0000 INFO (Worker-Interactive:SystemCommand-1a905ecb07562d54b965f7208c1ed06b) [AWorker:136] Worker completed: SystemCommand source: credentials_reload time: 0:00:02.296
2023-04-24T02:40:13.439+0000 INFO (ECCSender.1) [ECCSenderCache:349] Sending ecc_queue.1a905ecb07562d54b965f7208c1ed06b.xml
2023-04-24T02:40:18.204+0000 INFO (ECCQueueMonitor.1) [ECCQueueMonitor:384] Received message with timestamp: 2023-04-24 02:40:17. Existing Query window is : 2023-04-24 00:40:10, Updated the query window to: 2023-04-24 00:40:17
2023-04-24T02:40:18.204+0000 INFO (ECCQueueMonitor.1) [FileReadWrite:66] Time being written to the file : 1682296817000
2023-04-24T02:40:18.204+0000 INFO (Worker-Expedited:IPaaSActionProbe-04a0924707962d54b965f7208c1ed098) [AWorker:128] Worker starting: IPaaSActionProbe source: ff9092474a962d54ce7afd802d4d1707
2023-04-24T02:40:18.782+0000 INFO (Worker-Expedited:IPaaSActionProbe-04a0924707962d54b965f7208c1ed098) [AbstractHttpOperation:525] contextId=ff9092474a962d54ce7afd802d4d1707 IPaaSActionProbe | Credentials sys_id: 7e504a4707d22d54b965f7208c1ed061
2023-04-24T02:40:19.579+0000 INFO (Worker-Expedited:IPaaSActionProbe-04a0924707962d54b965f7208c1ed098) [ECCSender:208] Enqueuing: C:\ServiceNow\ServiceNow MID Server varanmidaws\agent\work\monitors\ECCSender\output_1\ecc_queue.04a0924707962d54b965f7208c1ed098.xml
2023-04-24T02:40:19.579+0000 INFO (Worker-Expedited:IPaaSActionProbe-04a0924707962d54b965f7208c1ed098) [AWorker:136] Worker completed: IPaaSActionProbe source: ff9092474a962d54ce7afd802d4d1707 time: 0:00:01.328
2023-04-24T02:40:19.938+0000 INFO (ECCSender.1) [ECCSenderCache:349] Sending ecc_queue.04a0924707962d54b965f7208c1ed098.xml
2023-04-24T02:40:34.250+0000 INFO (LogStatusMonitor.60) [LogStatusMonitor:50] 2023-04-24T02:40:34.250Z, stats threads: 93, memory max: 910.0mb, allocated: 292.0mb, used: 86.0mb, standard.queued: 0 probes, standard.processing: 0 probes, expedited.queued: 0 probes, expedited.processing: 0 probes, interactive.queued: 0 probes, interactive.processing: 0 probes
2023-04-24T02:40:48.263+0000 INFO (ECCQueueMonitor.1) [ECCQueueMonitor:384] Received message with timestamp: 2023-04-24 02:40:48. Existing Query window is : 2023-04-24 00:40:17, Updated the query window to: 2023-04-24 00:40:48
2023-04-24T02:40:48.263+0000 INFO (ECCQueueMonitor.1) [FileReadWrite:66] Time being written to the file : 1682296848000
2023-04-24T02:40:48.263+0000 INFO (Worker-Interactive:SystemCommand-5bb0924707962d54b965f7208c1ed00a) [AWorker:128] Worker starting: SystemCommand source: credentials_reload
2023-04-24T02:40:48.263+0000 INFO (Worker-Interactive:SystemCommand-5bb0924707962d54b965f7208c1ed00a) [Instance:934] Running system command: credentials_reload
2023-04-24T02:40:49.435+0000 INFO (Worker-Interactive:SystemCommand-5bb0924707962d54b965f7208c1ed00a) [StandardCredentialsProvider:396] 18 Credentials from instance loaded
2023-04-24T02:40:49.435+0000 INFO (Worker-Interactive:SystemCommand-5bb0924707962d54b965f7208c1ed00a) [MIDCredentialsConfigProvider$MyEventListener:83] com.service_now.mid.creds.provider.standard.StandardCredentialsProvider reloaded
2023-04-24T02:40:49.982+0000 INFO (Worker-Interactive:SystemCommand-5bb0924707962d54b965f7208c1ed00a) [StandardCredentialsProvider:396] 18 Credentials from instance loaded
2023-04-24T02:40:49.982+0000 INFO (Worker-Interactive:SystemCommand-5bb0924707962d54b965f7208c1ed00a) [MIDCredentialsConfigProvider$MyEventListener:83] com.service_now.mid.creds.provider.standard.StandardCredentialsProvider reloaded
2023-04-24T02:40:49.982+0000 INFO (Worker-Interactive:SystemCommand-5bb0924707962d54b965f7208c1ed00a) [ECCSender:208] Enqueuing: C:\ServiceNow\ServiceNow MID Server varanmidaws\agent\work\monitors\ECCSender\output_0\ecc_queue.5bb0924707962d54b965f7208c1ed00a.xml
2023-04-24T02:40:49.982+0000 INFO (Worker-Interactive:SystemCommand-5bb0924707962d54b965f7208c1ed00a) [AWorker:136] Worker completed: SystemCommand source: credentials_reload time: 0:00:01.719
2023-04-24T02:40:50.935+0000 INFO (ECCSender.1) [ECCSenderCache:349] Sending ecc_queue.5bb0924707962d54b965f7208c1ed00a.xml
2023-04-24T02:41:34.112+0000 INFO (LogStatusMonitor.60) [LogStatusMonitor:50] 2023-04-24T02:41:34.110Z, stats threads: 93, memory max: 910.0mb, allocated: 296.0mb, used: 84.0mb, standard.queued: 0 probes, standard.processing: 0 probes, expedited.queued: 0 probes, expedited.processing: 0 probes, interactive.queued: 0 probes, interactive.processing: 0 probes

 

1 ACCEPTED SOLUTION

VaranAwesomenow
Mega Sage

I figured it out, It was the properties file having incorrect credential format.

 

I made a recording of the solution.

 

https://youtu.be/7E23wu5J6rs

View solution in original post

In this video I will demonstrate how to use credential resolver setup of mid server to fetch basic authentication credentials from a file. Code :https://github.com/anilvaranasi/ServiceNow-file-based-credential-resolver
1 REPLY 1

VaranAwesomenow
Mega Sage

I figured it out, It was the properties file having incorrect credential format.

 

I made a recording of the solution.

 

https://youtu.be/7E23wu5J6rs

In this video I will demonstrate how to use credential resolver setup of mid server to fetch basic authentication credentials from a file. Code :https://github.com/anilvaranasi/ServiceNow-file-based-credential-resolver