Sign Up

Authenticating a Request

Why Authenticate Requests?

Authenticating requests is a crucial step in ensuring the security and integrity of your application's data. By validating the identity of users or systems that make API calls, you can prevent unauthorized access, data breaches, and potential misuse of your resources. Authentication also allows you to create personalized experiences and maintain audit trails for security and compliance purposes.

-

Prerequisites

Steps to Authenticate a Request

Generate a Signup Endpoint (/auth/signup)

  • Navigate to the API page in Twidget.

  • Click the Create Endpoint button located in the top-right corner.

  • In the newly opened sidebar, select Authentication.

  • Choose your authentication table from the "Select Table" dropdown.

  • Set the starting path to /auth.

  • Click the Sign Up endpoint (/auth/signup) and then click Create.

    This action will create the signup endpoint with the relevant inputs, commands, and outputs.

Create an Endpoint with Bearer Token Authentication

For this example, we will use the GET /table_1 endpoint which retrieves data from table_1.

Create API Requests in the API Client

  • First, create an API request for signing up.

  • Second, create an API request for retrieving data from table_1.

Sign Up Request Setup

  • Navigate to the signup request you created.

  • Click the path dropdown and select the /auth/signup endpoint. This will automatically update the method and path.

  • Add a body with a email and password, and then send the request.

  • You will receive an authentication token in the response. Save this token as you will use it to authenticate the data retrieval request.

Data Retrieval Request Setup

  • Navigate to the second request you created for the secured endpoint.

  • In the Authorization section, click the dropdown and select Bearer Token.

  • Paste your token into the token input field and send the request.

  • The request should succeed and you should receive a 200 response.

Handling Failed Requests

Failed requests will receive a 401 Unauthorized response. If you lose your authentication token, you can generate a login endpoint following the same steps used to create a signup endpoint. Use your login details to retrieve a new authentication token.

By following these steps, you can securely authenticate requests in your Twidget application, ensuring that only authorized users can access your data and resources.

Related Topics