Skip to main content

Custom authentication

Custom authentication gets a token from a token endpoint of your own, for APIs that do not use OAuth 2.0.

The token request​

Choose Custom Auth Request under Authentication Method in the HTTP connector, and describe the request that returns a token:

  • Request Method: The request method is GET, the default, or POST.
  • Authentication URL: The authentication URL is the address of your token endpoint, such as https://api.example.com/auth/token.
  • Query Parameters: Query parameters are added to the URL, such as a client name.
  • Request Body: The request body is sent as JSON with POST, built from the keys and values you add.

Values in query parameters and the body are shown as you entered them to anyone who may view connectors.

Reading the answer​

Three settings tell Send AI where the token is in the answer:

  • Token Key Name: The token key name is the key that holds the token, such as access_token. It must be at the top level of the answer.
  • Expiry Key Name: The expiry key name is the key that holds the expiry, such as expires_in.
  • Expiry Type: The expiry type says how to read the expiry: DateTime for the moment it expires, or Seconds and Milliseconds for how long it stays valid.

For example, this answer fits the token key access_token, the expiry key expires_in and the expiry type Seconds:

{ "access_token": "eyJhbGciOi...", "expires_in": 3600 }

How the token is used​

Every request carries the token as Authorization: Bearer <token>. Send AI reuses it until it expires and then requests a new one. When the expiry cannot be read, it requests a new token before every request.