简体   繁体   中英

ember-simple-auth facebook authenticator

Trying to hook up facebook authentication for my app. I've got the backend working correctly but my authenticator (I think this is the problem) is always returning 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?

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;

How can I better debug/solve what's going on here?

The problem was actually a simple error with the dataType used. It should be dataType: 'json' not dataType: 'application/json'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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