Skip to content

Authentication

Restorm has no “authentication type” dropdown. It has something more general: the authentication request, a fully fledged request whose job is to produce headers for the others.

The upside: any scheme can be modelled, including those no dropdown ever anticipates — a two-step exchange, a signed token, an in-house API. The downside: you have to write it once.

Right-click an environment folderAdd ▸ HTTP authentication request.

Configure the call first, like any HTTP request: method, URL, headers, body. Then open its Configuration tab, which carries the three settings specific to authentication.

The Configuration tab of an authentication request, with its three sections: the produced headers, the expiry in seconds and the authentication error codes

The list of headers this route will inject into every request that references it. Each value is an expression evaluated against the response body of the authentication request.

HeaderValue
Authorization{{token_type}} {{access_token}}

An expression, also evaluated against the response body, that gives the validity period in seconds — typically {{expires_in}}. Left empty, the token never expires by itself.

The HTTP statuses which, when received by a request using this route, trigger a token renewal followed by an automatic retry. By default: 401 and 403.

An authentication request is the item you create in the tree. An authentication route is that same item seen from another request, in the picker that attaches it. Both terms name the same entity, in two places in the interface.

On the request’s tab, in the smartbar, an Authentication route picker lists the environment folder’s routes. The default label is No authentication.

Once attached, the produced headers are injected on every send, the token is cached until it expires, and a 401 causes a transparent renewal.

Request: POST https://auth.exemple.test/oauth/token, body x-www-form-urlencoded with grant_type=client_credentials, client_id={{clientId}}, client_secret={{clientSecret}} (the secret being a Secret-typed value).

Produced header: Authorization = {{token_type}} {{access_token}}. Expiry: {{expires_in}}.

No request is needed if you already have the credentials: just set the header on the request (or on the folder):

Authorization = Basic {{base64Encode (append (append user ":") password)}}

A header or a query parameter is enough: X-API-Key = {{apiKey}}, with the key held in a Secret-typed variable.

Create a scenario: first call, extract the intermediate code, second call, then Set variable to place the token in the run variables. The scenario’s later requests read it with {{token}}.

When a specification is imported, the security schemes it declares are translated into pre-wired headers or parameters, with an environment variable created for you:

Scheme in the specificationWhat Restorm sets up
apiKey (header or query)A pair named after the scheme, value {{<schema>}}
http / basicAuthorization: Basic {{<schema>_credentials}}
http / bearer, oauth2, openIdConnectAuthorization: Bearer {{<schema>_token}}

All that is left is to fill in the variable, or to replace it with an authentication route if you want automatic renewal.

Some protocols do not go through HTTP headers. Their credentials are fields on the request itself:

ProtocolFields
MQTTusername, password, client identifier
AMQPusername, password, vhost
Redispassword
KafkaSASL mechanism (plain, scram-sha-256, scram-sha-512), identifier, password, TLS
STOMPThe CONNECT frame’s login and passcode headers
gRPCCall metadata

Every one of those passwords accepts a Secret-typed value.