Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Twitter popup remains open #417

Open
thomasMary opened this issue May 19, 2015 · 15 comments
Open

Twitter popup remains open #417

thomasMary opened this issue May 19, 2015 · 15 comments

Comments

@thomasMary
Copy link

Hi,

I'm using satelizer and passport to manager the Twitter authetifaction on my website, but the Twitter popup remains open after a successful authetification.
Here is what I've done:
Client: (127.0.0.1:9000)

angular.module('tstream').config(function ($stateProvider, $urlRouterProvider, $authProvider) {
    $authProvider.baseUrl = 'http://127.0.0.1:3001';
    $authProvider.twitter({ url: '/auth/twitter' });
    ...
angular.module('tstream.controllers').controller('TwitterCtrl', ['$scope','$auth',
  function ($scope,$auth) {
    $scope.login = function () {
      $auth.authenticate('twitter').then(function () {
        alert('YAY');
      });
    };
    ...

Server: (127.0.0.1:3001)

passport.use(new TwitterStrategy({
    consumerKey: cst.TWITTER_KEY,
    consumerSecret: cst.TWITTER_SECRET,
    callbackURL: "http://127.0.0.1:3001/auth/twitter/callback"
  },
  function(token, tokenSecret, profile, done) {
    return done(null, profile);
  }
));
router.get('/auth/twitter',
    passport.authenticate('twitter')
);
router.get('/auth/twitter/callback',
    passport.authenticate('twitter', { failureRedirect: '/' }),
    function(req, res) {
        res.redirect('/#/home');
    }
);

Here is a screenshot of my Twitter console

Do you have any idea what've done wrong?
Thanks

@Vincent-Noben
Copy link

Hi @sahat
I have a similar problem with nodejs, probably related.

  • I've my server running on localhost:3000 (and later on real server)
  • I've my angular client running on localhost:8080 seperate host from server
  • (I changed baseurl to server addres, withCredials to false, added cors on server, changed links in accounts.js to server addres etc to make that work)

When I hit login with twitter the popup opens and let's me login, but when I hit enter it callbacks to the localhost:3000 inside the popup window (without actually logging me in). I suppose it should close again and callback to the server, who then will notify my port 8080 client with a succesfull login and token. note: loggin in on when client is at same location as server works perfectly, this problem is when I split up server/client.

I tried rolling back to V0.10.0 (with .get route instead of new .post route on the express server) but that just gave a blanco popup page and does not work at all. (again, it does work when client is on server location)

I guess that's a minor bugg and hope it gets fixed quick :p
(as my graduation project deadline is 18 june and I would like to implement twitter as well)

EDIT:
I tried adding:
redirectUri: window.location.origin || window.location.protocol + '//' + window.location.host,
to satellizer.js because it was missing there for twitter but that did not solve the problem.

@aduffeck
Copy link

Hi,

I ran into the same problem in an ionic app. I managed to make it work by setting a proper oauth_callback parameter on the server side, but it's a bit tricky because the redirectUri paramater which would translate to it is not sent along to the server.

@sahat shouldn't the redirectUri be part of the POST request to the server?

@alexferl
Copy link

I have this issue as well.

I have both my web client and backend server behind nginx on port 3000.

When I click my Twitter icon, it opens up a popup window, does a POST to my backend, backend replies with the oauth_token and oauth_verifier, the popup window sets the callback URL in the location bar (http://localhost:3000?oauth_token=mytoken&oauth_verifier=myverifier) but then nothing is sent to the backend and my client is loaded in the popup window and nothing else happens.

Any ideas?

EDIT: If you want to see the issue I am talking about, run the go server in examples/ and it's exactly what's happening to me.

@cesardeazevedo
Copy link

@thomasMary what you mean with a "successful authetification"? did you see the twitter authorization button?

i've tried work (with successfully) with twitter-passport in the last two weeks, and i came to a conclusion that twitter-passport takes a complete different approach than satellizer examples.

@akkie
Copy link

akkie commented Jul 22, 2015

Same problem here. I get a blank white popup and nothing happens.

@joele75
Copy link

joele75 commented Aug 17, 2015

Same problem as admiralobvious - the popup loads with the client in place and the ?oauth_token=mytoken&oauth_verifier=myverifier are set but nothing else happens.

@joele75
Copy link

joele75 commented Aug 17, 2015

In my case, the issue was caused by the callback being 127.0.0.1:9000 but the original app URL was localhost:9000. So the poll function never sees that the popup has returned to the original location.

@cesardeazevedo
Copy link

Passport takes a different approach than satellizer,
I've forked password-twitter and put the satellizer approach, and it's working, maybe this help.
https://github.com/cesardeazevedo/passport-twitter-satellizer

@paulocheque
Copy link

@Vincent-Noben Did you solve the issue? I am facing a similar issue to yours: #629

@Vincent-Noben
Copy link

@paulocheque I'm sorry but no. I needed it for my graduation project but me and my teammate desided to completely abandon Social logins for our app due to bugs like this... Never looked at it again after our presentation. Sorry

@paulocheque
Copy link

But thanks for your time!

@ttlpta
Copy link

ttlpta commented Jun 27, 2016

I used PHP server. I have met this issue but when I add "redirectUri" is same like $requestTokenOauth's callback at server. The popup has close.
$authProvider.twitter({
url: '/auth/twitter',
redirectUri: 'http://localhost/angularjs-socialLogin/app/server/ci/auth/twitter'
});

with

$requestTokenOauth = new Oauth1([
'consumer_key' => $this->config->item('TWITTER_KEY'),
'consumer_secret' => $this->config->item('TWITTER_SECRET'),
'callback' => 'http://localhost/angularjs-socialLogin/app/server/ci/auth/twitter',
'token' => '',
'token_secret' => "'
]);

@aplanos
Copy link

aplanos commented Jul 31, 2016

Here my thoughts, Sattelizer open a popup waiting for a POST thats returns the OK, but Twitter is sending instead a GET inside the popup, so, sattelizer never gets to know that the flow is ended. Right now I have al my twitter authentication flow completed. But in the satellizer popup is showing the json data i'm returning. When I close manually the popup, the promise go to the failure saying popup was closed. What do you thing about this?

@Lasto13
Copy link

Lasto13 commented Sep 19, 2016

Hello, I wanted to ask about this issue, was it resolved ?

@aplanos
Copy link

aplanos commented Sep 19, 2016

Well I study the php server example solution, and I found a solution for my issue that was with .Net C# WebApi. I was using OAuthUtility and the response URL was being configured with GET Method. So, what I do was: Implement a fake GET and return then an empty response with Status 200 (OK) After that sattelizer get the flow control again and did a post to my server action.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests