0

I'm using Torii and ember-simple-auth to manage authentication on my front-side, and Knock and Omniauth-twitter on my server. I had no problem with Facebook, but Twitter using Oauth1.0, I have troubles to figure out the flow.

Here is my Torii config :

# environment.js

ENV['torii'] = {
sessionServiceName: 'sessiontorii',
providers: {
  'facebook-oauth2': {
    apiKey: 'API_KEY',
    redirectUri: 'http://localhost:4200/'
  },
  'twitter': {
    requestTokenUri: 'http://127.0.0.1:3000/auth/twitter'
  }
}

My route or controller :

# route.js

twitterLogin() {
  var self = this;
  this.get('sessiontorii').open('twitter').then(function(response) {
    console.log(response);

    self.transitionTo('index');
  }, function() {
    console.log('auth failed');
  });
},

A new window is opening and I can login with my Twitter account. My server does the authentication/registration, but I can't figure out how to close this new window and send the token to my front. Is my flow completely wrong ? Or do I miss something ? I followed this tutorial, but I wonder if it's not a bit outdated

j-printemps
  • 1,288
  • 11
  • 21
  • You may have a problem of origins : your main window being on localhost:4200 and the twitter one being on 127.0.0.1:3000. – Pierre Fraisse Apr 19 '17 at 09:22
  • Actually I figured out something, Torii is opening a new window, but it doesn't close it because it's still waiting for data. – j-printemps Apr 20 '17 at 03:13

1 Answers1

0

The issue was that I was sending a wrong type of data from my server. So I updated my torii-provider and the code I was sending. Torii does the job and close the new window when it gets the data. Then, I'm sending the data to my authenticator and confirm the authentication with the JWT code.

j-printemps
  • 1,288
  • 11
  • 21