ember-simple-auth脸书认证器
问题描述:
试图挂钩我的应用程序的Facebook认证。我有后端正常工作,但我的身份验证(我认为这是问题)总是返回undefined
。ember-simple-auth脸书认证器
从ember-simple-auth复制范例从第23行控制台登录是不会被调用,让我觉得别的什么问题?
import Ember from 'ember';
import Torii from 'ember-simple-auth/authenticators/torii';
const {inject: {service}} = Ember;
export default Torii.extend({
torii: service(),
ajax: service(),
authenticate() {
const ajax = this.get('ajax');
return this._super(...arguments).then((data) => {
return ajax.request('http://localhost:8080/api/login', {
type: 'POST',
dataType: 'application/json',
data: {
'grant_type': 'facebook_auth_code',
'auth_code': data.authorizationCode
}
}).then((response) => {
console.log("CALLED!");
return {
access_token: response,
provider: data.provider
};
});
});
}
});
服务器的响应是来自facebook的access_token;
我该如何更好地调试/解决这里发生的事情?
答
该问题实际上是一个简单的错误,使用dataType
。应该是dataType: 'json'
不是dataType: 'application/json'