Created
December 11, 2014 09:57
-
-
Save blackbing/f77d04cbed4b0059af2e to your computer and use it in GitHub Desktop.
[Firebase] Dealing with Popups and Redirects in a better way
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ref = new Firebase("https://<your-firebase>.firebaseio.com"); | |
rootRef.onAuth( function(authData){ | |
//It is a better way to get authData instead of get from auth callback function | |
console.log(authData); | |
}); | |
// prefer pop-ups, so we don't navigate away from the page | |
// auth callback is to handle if occur error | |
ref.authWithOAuthPopup("google", function(err) { | |
if (err) { | |
if (err.code === "TRANSPORT_UNAVAILABLE") { | |
// fall-back to browser redirects, and pick up the session | |
// automatically when we come back to the origin page | |
ref.authWithOAuthRedirect("google", function(err) { ... }); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment