Firebaseui-web: signInSuccessUrl always required

Created on 24 May 2016  路  18Comments  路  Source: firebase/firebaseui-web

The documentation states that the signInSuccessUrl is only required as follows.

signInSuccessUrl: The URL where to redirect the user after a successful sign-in. Required when the signInSuccess callback is not used or when it returns true.

However this is not the case. Currently by having the signInSuccess callback return false you can ignore the signInSuccessUrl, but it it still required otherwise the following error will be thrown and the signInSuccess function will not be called.

firebase-auth.js:48 Uncaught Error: Configuration signInSuccessUrl is required.

auth

Most helpful comment

I thought I'd just write the solution to this error
"No redirect URL has been found. You must either specify a signInSuccessUrl in the configuration, pass in a redirect URL to the widget URL, or return false from the callback"

All you need to do is return false in the signInSuccess callback

  const uiConfig = {
    callbacks: {
      signInSuccess: () => false,
    },

All 18 comments

signInSuccessUrl is currently always required even when false is returned in the callback.

Please make "signInSuccessUrl" optional. If it's set, do the redirect, if not - do nothing.
This leads to some strange behaviour. I use firebase for authentication on my server and when I want to access the id_token (it's fetched async via user.getToken()), in the meantime - while I'm waiting for the token - the redirect occurs.

We will work on making that optional. However for you case, return false in your sign in callback so no redirect happens while you call user.getToken() or on resolution, do the redirect manually.

I have the same issue. I hope it's fixed soon.

Just to clarify, the callback I was referring to is explained in the README.md in the "Example with all parameters used":
'callbacks': { 'signInSuccess': function(currentUser, credential, redirectUrl) { // No redirect. return false; } }

@bojeil-google could you expound a little for me. I'm extremely new to code and am having trouble redirecting manually. Here's what I tried. Any help would be greatly appreciated.

'callbacks': { 'signInSuccess': function(currentUser, credential, redirectUrl) { var user = currentUser; // var authenticated_URL = redirectUrl; if (user != null){ return true; authenticated_URL = 'https://google.com'; // authenticated_URL = '<my-website's-protected-page>; } else { return false; } } }

Hey @itispeach, the redirectUrl parameter is optional and will only be populate if you pass a signInSuccessUrl query parameter in the sign in widget url. I assume you are not passing. In addition signInSuccess callback will be triggered only when a user is logged in. So currentUser should always be populated. Here is one way you can do this:

'signInSuccessUrl': '<url-to-redirect-to-on-success>', 'callbacks': { 'signInSuccess': function(currentUser, credential, redirectUrl) { // This will redirect to redirectUrl if available or the signInSuccessUrl you specified in the config when // there is no redirectUrl. // return true; // If you to redirect manually, redirect here and return false. window.location.href = '<my-website's-protected-page>'; return false; } }

Hmmm, I'm still stuck. here's more of my code. I tried to apply your example, but I can still navigate strait to the "protected page" even though I'm in an incognito window. I must be missing a concept, here.

`

<script src="https://www.gstatic.com/firebasejs/ui/live/0.4/firebase-ui-auth.js"></script>

<script type="text/javascript">
  var uiConfig = {
      'queryParameterForWidgetMode': 'mode',
      'queryParameterForSignInSuccessUrl': 'signInSuccessUrl',
      'signInSuccessUrl': '<private-site-that-only-authenticated-users-can-visit>',
      'signInOptions': [
        firebase.auth.EmailAuthProvider.PROVIDER_ID
      ],
      'callbacks': {
        'signInSuccess': function(currentUser, credential, redirectUrl) {
          window.location.href = '<public-site-its-okay-to-visit>';
          return false;
        }
      }
    };
  </script>`

Do I need to use this somewhere? firebase.auth().onAuthStateChanged(function(user) {});

We fixed this issue in the new release. It will raise an error only if there is the signInSuccessUrl is required, i.e. if the signInSuccess callback returns true (i.e. proceed with redirect) and no redirectUrl has been given as a URL parameter, or that both signInSuccessUrl and signInSuccess callback are not given.

I thought I'd just write the solution to this error
"No redirect URL has been found. You must either specify a signInSuccessUrl in the configuration, pass in a redirect URL to the widget URL, or return false from the callback"

All you need to do is return false in the signInSuccess callback

  const uiConfig = {
    callbacks: {
      signInSuccess: () => false,
    },

@oliversisson Not work.

image

Your callback is returning a promise which evaluates to true.

@bojeil-google Oh, thanks, solved.

Screen Shot 2019-06-12 at 5 07 55 PM
Screen Shot 2019-06-12 at 5 07 09 PM

Still receiving this error, please help! @bojeil-google

You are returning a promise which resolves to true which triggers the redirect. Since no URL provided, an error is shown. Change the callback to be synchronous.

You are returning a promise which resolves to true which triggers the redirect. Since no URL provided, an error is shown. Change the callback to be synchronous.

@bojeil-google Is it possible to use async here?

@brandonfajardo I used this way and it worked for me.

image

Was this page helpful?
0 / 5 - 0 ratings