ember-simple-auth-torii Facebook提供商永远不会从开放功能中获得承诺

时间:2014-12-06 01:22:14

标签: ember-simple-auth torii

我正在使用ember-simple-auth-torii自定义Facebook OAuth2身份验证器,但我似乎永远无法让承诺返回任何数据(对于data.authorizationCode)。弹出窗口一直挂起,直到我关闭它,此时我收到popupClosed错误消息。

我错过了什么,我应该做什么?

谢谢!

FacebookAuthenticator = OAuth2.extend
  torii: null
  provider: "facebook-oauth2"
  authenticate: (credentials) ->
    that = this
    new Ember.RSVP.Promise((resolve, reject) ->
      that.torii.open(that.provider).then((data) ->
        data =
          facebook_auth_code: data.authorizationCode
        that.makeRequest(that.serverTokenEndpoint, data).then ((response) ->
          Ember.run ->
            expiresAt = that.absolutizeExpirationTime(response.expires_in)
            that.scheduleAccessTokenRefresh response.expires_in, expiresAt, response.refresh_token
            resolve Ember.$.extend(response,
              expires_at: expiresAt,
              access_token: response.access_token,
              user_id: response.user_id
            )
        ), (xhr) ->
          Ember.run ->
            reject xhr.responseJSON or xhr.responseText
        )
      )

FacebookAuthentication =
  name: "facebook-authentication"
  before: "simple-auth"
  after: 'torii'
  initialize: (container) ->
    Session.reopen
      user: (->
        userId = @get('user_id')
        if (!Ember.isEmpty(userId))
          return container.lookup('store:main').find('user', userId)
      ).property('userId')
    torii = container.lookup('torii:main')
    authenticator = FacebookAuthenticator.create
      torii: torii
    container.register("authenticator:facebook", authenticator, {
      instantiate: false  
    })

`export default FacebookAuthentication`

1 个答案:

答案 0 :(得分:0)

我遇到的问题是网址不正确。

您需要在Facebook的高级应用设置中设置网址,并确保其与您在redirectUri中指定的ember-cli应用相同的网址。

Facebook settings