Passwordless Authentication in Bubble.io API Workflows
The traditional password system often feels like a flimsy lock on the doors of our digital fortresses. How often have we struggled to remember complex passwords or feared the consequences of a data breach due to a forgotten or compromised password? Passwords alone may no longer suffice to safeguard our online identities.
Passwordless authentication is a paradigm shift in how we verify our digital selves. In this age of innovation, where Bubble.io empowers us to create dynamic web applications, it’s only fitting that we explore new, more secure methods for user authentication.
So, whether you’re a seasoned developer or just dipping your toes into the world of web app creation, fasten your seatbelt because we’re about to demystify the art of passwordless authentication in Bubble.io. Let’s explore this cutting-edge approach to digital security, where convenience meets robust protection.
Exploring Passwordless Authentication in Bubble.io API Workflows
As I began into APIs, I quickly discovered that Bubble.io initially expects a traditional username and password combo for login actions within API workflows. However, don’t worry – there’s a straightforward workaround.
You’ll need to generate a unique API key for each user to get started.

It is a group consisting of a button and an HTML element.

Inside that HTML element, you’ll find some clever JavaScript I borrowed from a fellow developer on this Bubble forum.

`<input type=“text” id=“APIkey” size=“10” value=Current User’s my_API_key>
copy API key`
Let’s create a workflow for the “new API key” button. In this workflow, instruct it to “Make changes to the user.” Choose the “current user” option, then place a randomly generated string into the field where you store the user’s current API key. Ensure you’ve already created a field to store that API key for each user.

Ensure that you place this API-key-generating group somewhere accessible only to logged-in users. This way, users can effortlessly obtain an API key whenever they require one, and they even have the option to change it if necessary. Think of this API key as their digital “password” when they attempt to authenticate via the API.
Now, let’s move on. You’ll need at least one API workflow that doesn’t require prior authentication. This specific workflow serves as the gateway to authenticate users, enabling them to access other workflows with authentication requirements subsequently. The login process for the API operates much like it does within the broader Bubble framework, and we’ll employ a similar “hack” to make it work seamlessly.

Here’s the next step: The user initiates a POST request to the API endpoint, supplying their registered email address (the one they’ve already used in the app) and the API key (which they’ve previously copied after logging in).
What happens next is pretty cool. We conduct our little investigation by checking these two pieces of information. We search for users who have both the provided email and API key. If we find a match, we record that they’ve successfully used their API key to log in.

Now, moving right along, our next task is to assign a temporary password to the user we identified in the previous step.

Lastly, to wrap it up, we’ll log in to the user we identified in step one. For this purpose, we’ll use the email provided in the POST request and the password we generated in step 2.

When this process runs smoothly and successfully, it will provide you with a small JSON package. Inside this JSON, you’ll find two crucial elements: a “user_id” parameter, which represents the unique ID of the user who has just been logged in, and a “token” parameter.
Here’s the trick: Take this JSON, especially the “token,” and insert it into the header of your subsequent POST requests to API endpoints that require authentication. Replace “###” with the token you’ve just been issued. This token is your golden ticket, granting access to secure areas of your application’s functionality.
Content-Type: application/json Authorization: Bearer ###
Source: https://forum.bubble.io/t/how-to-passwordless-authentication-in-api-workflow/8986
Final Thoughts
Passwordless authentication in API workflows is just one example of how innovation continues to reshape the digital world. As you journey through this guide, you’ve unlocked the power to enhance the security and convenience of your Bubble.io applications.
Remember, every line of code you write or every workflow you design is a step towards shaping a better digital future. Embrace the limitless possibilities of no-code and low-code development.
And when you find yourself facing questions or hurdles, know that you’re not alone. BubbleHelpers is here for you, ready to provide the support you need to overcome any challenge. Whether you’re a seasoned developer or just beginning your coding journey, we’re your steadfast companions in the no-code and low-code app development world.
So, go forth confidently, innovate fearlessly, and continue pushing the boundaries of what’s possible. Your creations have the potential to transform industries, enrich lives, and leave an indelible mark on the digital landscape. The future is yours to build, and BubbleHelpers is here to help you every step of the way.