Redirect to different page after oauth log-in

After clicking “log in” in my site header, I want the user to be redirected to a login page where they can log-in using Google Oauth, and then be redirected back to the page they were first visiting when they first clicked “log in” in the header.

Unfortunately, Google Oauth is very strict about the URL that the user is coming from when logging in which is hindering all the solutions that I can come up with.

Has anyone had experience with this or has any tips for achieving my desired result? Thanks

If you’re using Bubble’s oauth, then you can add a redirection action in the workflow after login action.

1 Like

My main problem is getting Bubble to temporarily store the URL that I would like to redirect the user to after they have logged in.

I can’t store the URL in a ‘state’ on the page because Google OAuth directs the user away from the site while logging in and clears the page’s states.

I can’t store the URL on the unlogged-in user using the Database because after they return from logging in, the database information doesn’t carry-over from when they were logged out.

I can’t store the URL as a parameter on the login page address because google OAuth is too strict and won’t let you log in if the address is not exactly correct.

Perhaps there is another way to store the URL until after the user is logged in? I think storing it as a cookie would work but it feels complicated and I’ve not messed with that stuff before so would prefer a more simple method if possible.

  1. Storing URL as a parameter is possible. I use it on my login page like shown below. After google login is done, the page is refreshed with same parameters and hence you can use those.

  1. In the workflow that you have on Oauth login, after the action of “sign-up/login”, you can have other actions which are actually executed after user logs in. Not sure how Bubble does it. Maybe Bubble makes a note of these actions and then performs in the backend. Not sure. Here is how it is in my setup.

Now it is possible that these actions might be getting executed every time irrespective of whether login worked or not. I haven’t tested that part. For me anyway it doesn’t matter as if the login failed then subsequent actions would work on null object.

Thanks for your responses so far.

“1. storing URL as a parameter is possible…”

Google OAuth won’t let the user log in if the URL they are coming from is not the exact URL that has been set up in the google developer console. Otherwise they get a “redirect_URI_mismatch” error when trying to log in.

If I send the ‘target url’ as a parameter to my Login page, it changes the URL of my login page because it adds that parameter onto the end of the URL

e.g. “” becomes “”. Unfortunately google OAuth only recognises and not The user is therefore not able to log in when the target URL is stored as a parameter.

It doesn’t seem like that solution works as a way to temporarily store the target url so that I can use it in a workflow.

bump, any ideas?

Solved this ‘temporarily storing the URL’ problem by installing the “local storage and cookies” plugin which stores the URL as a local browser cookie rather than in Bubble’s database or in page states.

If anyone runs into the same problem and needs more help, let me know and happy to provide more details.


It does work for me.

Try hitting this:

Now login with Google and it will take you to contact-us page afterwards.

Clearly is working for you so really not sure what was going wrong on my end with my app!

Whenever a user tries to log in with Google from a URL that has parameters, or anything different from the URL I’ve set up in google developer console, they get this error:

These are the only URLs that a user is able to log in from:

Should I have set up my settings in google dev console differently? Not sure how to allow ‘any’ URL to log in rather than just the specific ones i’ve added to Google dev console.

These are two settings that I have and I think they may be making the difference.

In Google plugin in Bubble:

In Google Cloud Console:

1 Like

So does this work? Can I put a button on every page and I will not get an error? (especially when I have URL Parameters)

Try it out and see?

it comes with error

:grinning: And you do not want to share the error. How does one help with that?

1 Like

@mghatiya Very nice response :smiley:

It comes with this error:

Thanks for the answer

Have you gone through my post ?

Were you able to try what is mentioned there?

1 Like

I forgot to add the API-URL to the Google Console oAuth :sweat_smile:

I would like to know more about it. Thanks