Get Started

Theme switcher

API Authentication

API authentication is a crucial step for securing your API and ensuring that only authorized users can access it. In Theneo, you can easily set up authentication using HTTP Basic Auth, where your API key is included in the HTTP request headers. This process verifies your identity and grants access to the API’s resources.

Theneo offers two ways to configure API authentication:

  1. From the Theneo Editor
  2. Using Pre-request Scripts from the Project Dashboard

Setting API Authentication from the Theneo Editor

Follow these steps to set up authentication directly within the Theneo editor:

1

Navigate to the API Management Widget:

  • Open your project in the Theneo editor.
  • Select the API Management Widget where you can manage your API endpoints.
2

Access the Header Tab:

  • In the Header Tab, you will see a list of suggested key options for your headers.
  • Select the Authentication option from this list.
3

Add Authentication Information:

  • Enter a sample value for the authentication header. This can be configured or updated in the API Explorer.
  • Optionally, add a description or any additional properties that your API requires.

Setting API Authentication Using Pre-request Scripts

For more advanced use cases, you can configure authentication using pre-request scripts. Here’s how you can do it:

1

Navigate to the Project Settings:

In the Project’s Dashboard, go to the Project Settings.

2

Set an Authentication Header

For example, to set an Authorization header, you can write:

JavaScript
const token = theneo.variables["authToken"]; theneo.headers["Authorization"] = Bearer ${token};

In your pre-request script, you can send requests to other endpoints or set headers dynamically using the Fetch API or similar methods.

This script retrieves an authorization token from Theneo variables and applies it to the Authorization header.

For more details on how to effectively use pre-request scripts in Theneo, visit our detailed guide

Was this section helpful?

What made this section unhelpful for you?

On this page
  • API Authentication