Giter VIP home page Giter VIP logo

Comments (19)

oliversisson avatar oliversisson commented on August 15, 2024 9

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,
    },

from firebaseui-web.

alipetarian avatar alipetarian commented on August 15, 2024 7

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

image

from firebaseui-web.

 avatar commented on August 15, 2024 4

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.

from firebaseui-web.

bojeil-google avatar bojeil-google commented on August 15, 2024 3

Your callback is returning a promise which evaluates to true.

from firebaseui-web.

bojeil-google avatar bojeil-google commented on August 15, 2024 2

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.

from firebaseui-web.

bojeil-google avatar bojeil-google commented on August 15, 2024 1

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.

from firebaseui-web.

brandonfajardo avatar brandonfajardo commented on August 15, 2024 1

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?

from firebaseui-web.

bojeil-google avatar bojeil-google commented on August 15, 2024

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

from firebaseui-web.

alexkreidler avatar alexkreidler commented on August 15, 2024

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

from firebaseui-web.

bojeil-google avatar bojeil-google commented on August 15, 2024

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; } }

from firebaseui-web.

itispeach avatar itispeach commented on August 15, 2024

@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; } } }

from firebaseui-web.

bojeil-google avatar bojeil-google commented on August 15, 2024

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; } }

from firebaseui-web.

itispeach avatar itispeach commented on August 15, 2024

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/3.1.0/firebase.js"></script>
<script>
var config = {
apiKey: "give-this-to-no-one",
authDomain: "nor this",
databaseURL: "can't share this",
storageBucket: "for-me-to-know-and-you-to-find-out",
};
firebase.initializeApp(config);
</script>

<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) {});

from firebaseui-web.

bojeil-google avatar bojeil-google commented on August 15, 2024

Hey @itispeach, check the response I gave on stackoverflow:
http://stackoverflow.com/questions/38191852/is-there-a-signinfailureurl-parameter-for-github-project-firebaseui-for-web

from firebaseui-web.

TMSCH avatar TMSCH commented on August 15, 2024

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.

from firebaseui-web.

GF-Huang avatar GF-Huang commented on August 15, 2024

@oliversisson Not work.

image

from firebaseui-web.

GF-Huang avatar GF-Huang commented on August 15, 2024

@bojeil-google Oh, thanks, solved.

from firebaseui-web.

brandonfajardo avatar brandonfajardo commented on August 15, 2024

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

from firebaseui-web.

Chuiantw1212 avatar Chuiantw1212 commented on August 15, 2024

Why is this issue closed? Having a not so making sense work around did not really solve the problem.
In modern framework, it is a common scenario to route to various paths after signed in.

It is logical to make this field optional,
considering making it optional won't make a breaking change.

from firebaseui-web.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.