Forum Academy Marketplace Showcase Pricing Features

Log a user in from javascript


I am trying to use Firebase auth for handling sign-up/login in my application.

I have managed to put Firebase authentication which is working. I had to add some javascripts and Firebase’s code in that.

However, problem I am facing is I don’t know what to do when user logs in. I want to tell Bubble to log the user in. I have the credentials about which user I want to login, but how to tell Bubble about it from Javascript?

I did API call, but API call runs in the backend and don’t know if it can link my user’s front end session with it.

Can someone guide here? Hope I was able to explain my issue well.


When you authenticate with the api, do you get a response?

Usually you’d get back a users uid and other profile info. A Firebase user object can contain a lot of info.

Thanks Jared for the response.

I get the response with info like uid etc. I am calling an API workflow that I have created, to log the user in when I get the “sign in” event. But API workflow works in the backend. I don’t think it connects to the front end where I call the API from. So basically in front end user never logs in. It logs in in some empty space.

Do you have to run the login action as a backend workflow? Why do it that way?

If it’s front end you can use a workflow like

  • On button click log user in (the api call should be an action and not a data type)

  • in that workflow, set a state on the page to hold step 1’s Firebase login uid

Have another workflow like

When page states uid is not empty
Log user in

Another question would be, do you have to use both methods?

Firebase and bubble login

Maybe I have chosen to do it the wrong way. But I did it the way I understood by reading here and there.

I basically want people to login via Firebase (because I want SMS based login) and since I am using Bubble to build everything, I do need to log the user in in Bubble too so that I can perform rest of the actions.

In the front end, I have a javascript file that I load which shows up Firebase login screen etc. That file also has a success handler that is called when user successfully logs in. So I get to know that user has logged in successfully, in javascript. Now how do I tell Bubble that so and so user has logged in? I thought I would do it by calling an API. And hence API workflow.

What is better and right way of going about it?

I just came across this: Reference | Bubble

Now I am even more confused. Looks like API workflow will work for login and sign-ups too. But I am facing some issues. My front-end doesn’t get to know about login taking place, even though I see in the Logs that user did login.

I think the issue that you’re experiencing is that your JavaScript code is not telling the mobile app that you’re logged in. You need to trigger an event for the mobile app. You cannot do that from JavaScript code alone but I believe that there is a plug-in called toolbox that lets you do that. The same could also be accomplished by building a plug-in specifically for the new case. That’s what I did.

Can you show me the api call workflow for signing a user in?

You can look at my firebase login javascript code here:

The API workflow that is called is shown in this screenshot.

Will this suffice for you or you’d like to look at the editor?