How to retrieve credentials in Flow Designer REST step?

rcz
Giga Contributor

Hi,

I'm authenticating with a JSON-RPC 2.0 API (Zabbix) inside a Flow Designer Action.

To get an API token, I currently use a REST step to submit username and password to the API:

# POST /api_jsonrpc.php
{
  "jsonrpc": "2.0",
  "method": "user.login",
  "params": {
    "user": "ServiceNow",
    "password": "password"
  },
  "id": 1
}

This works fine. But I would like to avoid hardcoding the credentials in the script or supply them as an input to the whole Action.

I do use a Connection Alias. With other authentication methods, you can attach credentials to the alias, but this is not available for JSON-RPC authentication.

Is there another way to retrieve credentials inside the request body?

Thanks!

8 REPLIES 8

Geoff_T
Mega Sage

Hello,

Are you aware of the StandardCredentialsProvider API:

https://developer.servicenow.com/dev.do#!/reference/api/orlando/server/sn_cc-namespace/standardcredentialsprovider-api

 

This allows you to retrieve username / password from a credential record.

 

Let me know if this helps/answers you question.

 

Geoff

rcz
Giga Contributor

This would require another step before the REST call, thus requiring me to know which credentials were selected beforehand.

It would also mean hardcoding an ID or having the flow designer pick a credential every time they use the action.

The REST step already knows the credentials as they are attached to the connection. Can't you extract this?

If not, what exactly is the "Credential Value" variable?

If you have a credential record with the User Name / Password you can pass that record as an input to the action:

find_real_file.png

 

 

find_real_file.png

 

 

Geoff

Ty7
Tera Contributor

Hi Geoff,

 

I have a similar issue as the op and attempted to use the credential record to pass the password into the body of a rest call as you've mentioned above. For some reason I am getting access denied when I use the credential record password data pill. 

Is the password data pill encrypted or passed as a string?