2016-11-20 88 views
0

試圖掛鉤我的應用程序的Facebook認證。我有後端正常工作,但我的身份驗證(我認爲這是問題)總是返回undefinedember-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;

我該如何更好地調試/解決這裏發生的事情?

回答

0

該問題實際上是一個簡單的錯誤,使用dataType。應該是dataType: 'json'不是dataType: 'application/json'