mardi 18 avril 2017

Twitter authentication with Ember.js and Rails

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://ift.tt/2o1IHmW'
  }
}

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 ?




Aucun commentaire:

Enregistrer un commentaire