简体   繁体   English

使用Ember.js和Rails进行Twitter身份验证

[英]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. 我使用Torii和ember-simple-auth在前端管理身份验证,并在服务器上管理Knock和Omniauth-twitter。 I had no problem with Facebook, but Twitter using Oauth1.0, I have troubles to figure out the flow. 我对Facebook没问题,但是使用Oauth1.0的Twitter,我很难弄清楚流程。

Here is my Torii config : 这是我的Torii配置:

# 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. 一个新的窗口打开,我可以用我的Twitter帐户登录。 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 我遵循了本教程 ,但是我想知道它是否还有些过时

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提供程序和正在发送的代码。 Torii does the job and close the new window when it gets the data. Torii完成该工作,并在获取数据时关闭新窗口。 Then, I'm sending the data to my authenticator and confirm the authentication with the JWT code. 然后,我将数据发送到我的身份验证器,并使用JWT代码确认身份验证。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM