Firebase angular $ authWithOAuthRedirect

I use Firebase and Angular and Angular fire to enter OAuth.

Everything works fine when I use $authWithOAuthPopup, but this transport is not always available, so when I have to drop it on $authWithOAuthRedirect, I can not get it to work.

Using this code, the following happens:

  • Perform the login function (twitter)
  • See "CHECK 1" in the console.
  • The user redirects the twitter OAuth stream (url looks something like this: https://api.twitter.com/oauth/authenticate?oauth_token=<longtoken>
  • The user redirects back to my Angular application (URL looks like this: http://localhost:3101/##?&__firebase_request_key=<longrequestkey>

Mandatory Callbacks: CHECK 2, CHECK 3, CHECK 4never executed, and the function onAuth $ ( CHECK 5) never run.

If I use $ authWithOAuthPopup, it works as expected (as long as this transport is supported).


authObj = $firebaseAuth new Firebase(<firebase root>);
authObj.$onAuth(function(authData){
  console.log("CHECK 5");
});


$scope.login = function(provider) {
  console.log("CHECK 1");
  authObj.$authWithOAuthRedirect(provider).then(function(authData) {
    console.log("CHECK 2");
  }).then(function() {
    console.log("CHECK 3");
  }).catch(function(err) {
    console.log("CHECK 4");
  });
}

I tried to reproduce this with another example: https://dylan.firebaseapp.com/ . In this reproduced example, everything is working fine. This is something else in my application causing a fun business.

Libraries:

+4
source share

Source: https://habr.com/ru/post/1615990/


All Articles