Skip to main content

How do I manage and store API tokens in Bubble using the 'Signup/login with API' workflow action?

Sofia Maconi avatar
Written by Sofia Maconi
Updated over a month ago

Managing and Storing API Tokens in Bubble During the 'Signup/login with API' Workflow

The 'Signup/login with API' workflow in Bubble allows users to integrate their app with external authentication systems. A key component of this process is managing the API token returned from the external provider. Below are detailed instructions on how to access, store, and use these tokens effectively.

Overview of Token Retrieval

When using the 'Signup/login with API' workflow, the token is included in the API response. This response typically contains fields such as:

  • access_token (the API token itself)

  • expires_in (the token expiration time)

  • user_id (the associated user identifier)

Steps to Access the Token

  1. After executing the workflow action, reference the API response using the "Result of step X" method within the Bubble editor.

  2. To view the token directly, you can use a text element or alert and display the token field from the response, e.g., "Result of step X's token."

Methods to Store the API Token

There are two main options for storing the API token based on your use case:

1. Persistent Storage in the Database

To make the token available across sessions:

  • Add a custom field to your User data type (e.g., API Token).

  • Use the "Make changes to User" action to save the token from the API response to the database.

  • This allows the token to be reused for future API calls.

2. Temporary Storage in a Custom State

If the token is only required temporarily (e.g., during a single workflow or session):

  • Use a custom state to store the token.

  • Note that custom states are cleared when the page is refreshed, so this method is best for short-term use.

Troubleshooting Token Field Configuration

If you experience issues, such as missing fields like access_token or expires_in in the API response, consider the following:

  • Confirm with your API provider (e.g., Google) that your authorization URL is correctly configured. For Google APIs, include access_type=offline to ensure a refresh token is included.

  • Use tools like Postman or Bubble's API Connector logging to inspect the token response and verify it contains the expected fields.

  • Adjust your request parameters or contact the API provider for further assistance to align token responses with Bubble’s requirements.

Did this answer your question?