【问题标题】:ember-simple-auth facebook authenticatorember-simple-auth Facebook 身份验证器
【发布时间】:2016-11-20 17:23:38
【问题描述】:

尝试为我的应用程序连接 facebook 身份验证。我的后端工作正常,但我的身份验证器(我认为这是问题所在)总是返回undefined。

从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;

我怎样才能更好地调试/解决这里发生的事情?

【问题讨论】:

    标签: facebook authentication ember.js ember-simple-auth


    【解决方案1】:

    问题实际上是使用 dataType 的一个简单错误。应该是dataType: 'json' 而不是dataType: 'application/json'

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多