Query Authentication provides the simplest authentication method, in which the credentials are sent in the request URL. This is most often used with APIs which are authenticated using API tokens and signatures. Dynamic values of query parameters can be generated using user functions.
A sample Query authentication configuration looks like this:
{
"api": {
...,
"authentication": {
"type": "query",
"query": {
"apikey": "2267709"
}
}
}
}
The following configuration parameters are supported for the query
type of authentication:
query
(required, object) — an object whose properties represent key-value pairs of the URL queryLet’s say you have an API which requires an api-token
parameter (with value 2267709) to be sent with
each request. The following authentication configuration does exactly that:
"authentication": {
"type": "query",
"query": {
"api-token": "2267709"
}
}
For this use case, it is also possible to use the defaultOptions
setting.
However, we recommend using the authentication
setting for credentials so that the Generic Extractor
configuration does not become a complete mess.
See example [EX077].
Usually you want the value used for authentication encrypted (the api-token
parameter with the value 2267709 in our example), so you are not exposing it to other users and also not storing it in the configuration versions history. The following authentication configuration combined with the parameter defined in the config
section does that (the value with the prefix #
is encrypted upon saving the configuration):
{
"api": {
...,
"authentication": {
"type": "query",
"query": {
"api-token": {
"attr": "#token"
}
}
}
},
"config": {
...,
"#token": "2267709"
}
}
}
See example [EX094].