mardi 24 mars 2015

How to avoid redirect loop when using Firebase's authWithOAuthRedirect


Vote count:

0




I have the following code running, which results in the page continuing to attempt to reload and the user never appearing to be authenticated. It should be noted that this works as expected when using the authWithOAuthPopup method.



var myDataRef = new Firebase("http://ift.tt/1f03fwj");

var existingAuthData = myDataRef.getAuth(); //After the oauth redirect and every subsequent load, this is always null

//register onAuth listener
myDataRef.onAuth(function(authData) {
//We never get this far as the page continues to attempt to load
if (authData !== null){
console.log('logged in now!')
}
else {
console.log('not logged in yet')
}
})

if (existingAuthData !== null) {
console.log('User already logged in');
}
else {
console.log('getAuth returned nothing - authenticating');
myDataRef.authWithOAuthRedirect("github", function(error, authData) {
if (error) {
console.log("Login Failed!", error);
} else {
console.log("Authenticated successfully with payload:", authData);
}
});
}


After authenticating with github the page is redirected back to my custom domain with a hash appended: #&__firebase_request_key=Qwnn9TtM2fsIHq44vhCcbXbPa0DMPL1N.


The page then reloads, leaving just the # in the url, before reloading again with the firebase_request_key hash. This continues indefinitely.


Again, it's worth noting that this works as expected if I switch the authWithOAuthRedirect method for authWithOAuthPopup.


How can I get the redirect method to work the way I'm expecting it to?



asked 1 min ago

Andy F

603






How to avoid redirect loop when using Firebase's authWithOAuthRedirect

Aucun commentaire:

Enregistrer un commentaire