HTTP Request Agent Credential

With the HTTP Request Agent Credential type, data retrieved from the response of an HTTP Request Agent can be used with a credential widget. When an agent with a HTTP Request Agent credential runs, Tines will run the corresponding HTTP Request Agent options in the background and embed the data at the specified path in the response.

Creating a HTTP Request Agent Credential

When creating a HTTP Request Agent Credential, you will need to specify the name of the credential, HTTP Request Agent options and the JSONPath where the data that should be used in the credential can be located in the response.

Example

Suppose we have HTTP Request Agent options that make a request to a service to get an access token for subsequent requests. The agent config for this agent is shown below:

{
  "url": "https://www.token-generator.com/oauth2/token",
  "content_type": "form",
  "method": "post",
  "payload": {
    "assertion": "{% credential token_generator %}"
  }
}

When this agent runs, it emits an event similar that shown below:

{
  "get_auth_token": {
    "body": {
      "access_token": "ya29.Gn9qB-2K9xbys1DCgzyXNrIWuIIE0CuoAuSj5dYqWiMa7JNjarCZxhjgxbPkAGtADLIck87KIuDtYp3o71NRppfyA2tpTfD1uRG6lsjfoQD4g86jbzyjcTLbOn-oD_i8eQf4hQnUhkcrrktQ70GBJmnLwrOCaH7bTthMQLzV21p5",
      "expires_in": 3600,
      "token_type": "Bearer"
    },
    "headers": {},
    "status": 200
  }
}

We would use the access_token defined at {{.get_auth_token.body.access_token}} in subsequent requests.

HTTP Request Agent Credential Options
HTTP Request Agent Credential Options
HTTP Request Agent Credential Location of token
HTTP Request Agent Credential Location of token

We can now use another HTTP Request Agent to make requests using the new credential. When the below agent runs, it will first run the Get auth token credential in the background, extract the returned access_token and embed it in Authorization header, where the credential widget is defined:

{
  "url": "https://www.another-service.com/admin/login",
  "content_type": "json",
  "method": "get",
  "headers": {
    "Authorization": "Bearer {{ .CREDENTIAL.get_auth_token }}"
  }
}