我尝试使用Torii和Simple-Auth Torii authenticationator设置 facebook 登录。我正在使用 ember-cli。
这是我的配置:
// config/environment.js
ENV['torii'] = {
providers: {
'facebook-oauth2': {
apiKey: 'my facebook app id'
}
}
}
这是我的登录代码:
// app/controllers/login.js
import Ember from 'ember';
import LoginControllerMixin from 'simple-auth/mixins/login-controller-mixin';
export default Ember.Controller.extend(LoginControllerMixin, {
actions: {
authenticateWithTorii: function(){
this.get('session').authenticate(
'simple-auth-authenticator:torii',
'facebook-oauth2'
).then(
function(data) {
alert('SUCCESS ' + data);
},
function(error) {
alert('There was an error when trying to sign you in: ' + error);
}
);
}
}
});
弹出窗口正在打开请求授权,然后我看到带有“SUCCESS UNDEFINED”的警报。我想我会得到一些我可以在我的后端使用的数据来肯定地验证用户(访问令牌或 facebook uid 等......)。
我是否错过了将 Torii 与 Simple-Auth 一起使用的方式?