简体   繁体   中英

Cannot read property “authenticate” of undefined - Parse Server with Account Kit

Issue Description

I am using Parse Server 3.0.0 and trying to get it to work with Facebook's Account Kit. I have followed the instructions in the docs and done the following:

  1. Configured facebookaccountkit inside auth passed to ParseServer()

var polaris = new ParseServer({
  databaseURI: 'mongodb://localhost:27017/polaris',
  cloud: __dirname + '/cloud/main.js',
  appId: 'polarisAppId',
  masterKey: 'polarisMasterKey',
  serverURL: 'http://' + ipAddress + ':1337/polaris',
  auth: {
    facebookaccountkit: {
      appIds: ["app_id_here"],
      appSecret: "app_secret_here"
    },
  }
});
  1. Getting Access Token inside my Android by going through phone verification.
  2. Calling _linkWith() in cloud code as:

let accountKitAuthData = {
    "id": accountKitId,
    "access_token": accessToken,
    "last_refresh": lastRefresh
}

let user = new Parse.User()
user._linkWith('facebookaccountkit', accountKitAuthData).then(function (user) {
    console.log("linkWith method finished ")
    console.log("user object type " + (typeof user))
});

However, after all this, I am getting the following error:

(node:21807) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'authenticate' of undefined`

My best guess is that the facebookaccountkit provider is not getting registered due to some reason but I may be wrong. Please help!

Expected Results

Linking of user with facebookaccountkit credentials

Actual Outcome

Error:

(node:21807) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'authenticate' of undefined`

Environment Setup

  • Server
    • parse-server version : 3.0.0
    • Operating System: Ubuntu
    • Hardware: -
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): Google Cloud Platform

Use this:

let accountKitAuthData = {
    "id": accountKitId,
    "access_token": accessToken,
    "last_refresh": lastRefresh
}

let user = new Parse.User()
user._linkWith('facebookaccountkit', { authData: accountKitAuthData }).then(function (user) {
    console.log("linkWith method finished ")
    console.log("user object type " + (typeof user))
});

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