Skip to content

Instantly share code, notes, and snippets.

@blackbing
Created December 11, 2014 09:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blackbing/f77d04cbed4b0059af2e to your computer and use it in GitHub Desktop.
Save blackbing/f77d04cbed4b0059af2e to your computer and use it in GitHub Desktop.
[Firebase] Dealing with Popups and Redirects in a better way
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