简体   繁体   English

ember-simple-auth facebook身份验证器

[英]ember-simple-auth facebook authenticator

Trying to hook up facebook authentication for my app. 尝试为我的应用程序连接facebook身份验证。 I've got the backend working correctly but my authenticator (I think this is the problem) is always returning undefined . 我的后端正常工作,但是我的身份验证器(我认为这是问题所在)始终返回undefined

Copying the example from from ember-simple-auth the console log on line 23 is never called, making me think something else the issue? 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
        };
      });
    });
  }
});

The response from the server is the access_token from facebook; 服务器的响应是来自facebook的access_token;

How can I better debug/solve what's going on here? 如何更好地调试/解决这里发生的事情?

The problem was actually a simple error with the dataType used. 问题实际上是使用的dataType一个简单错误。 It should be dataType: 'json' not dataType: 'application/json' 应该是dataType: 'json'而不是dataType: 'application/json'

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

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