使用Facebook登录解析服务器时出错

时间:2016-01-30 00:59:22

标签: ios facebook mongodb heroku parse-server

我是使用https://parse.com/docs/server/guide作为向导,从Parse迁移到Heroku(带MongoLab沙箱)的众多用户之一。

迁移的事情进展顺利(可以通过远程仓库上的REST命令创建/检索对象),直到我尝试使用(iOS)Facebook登录。

方法:

[PFFacebookUtils logInInBackgroundWithReadPermissions: ... ]
在Parse托管时已经工作的

现在返回以下错误:

[Error]: Facebook auth is invalid for this user. (Code: 101, Version: 1.12.0)

注意:对我(之前正在运行的)iOS代码的唯一更改是将Parse服务器指向我新的手动托管的repo,如下所示:

 let parseConfiguration = ParseClientConfiguration(block: { (ParseMutableClientConfiguration) -> Void in
        ParseMutableClientConfiguration.applicationId = "<*APP ID*>"
        ParseMutableClientConfiguration.clientKey = "<*CLIENT KEY*>"
        ParseMutableClientConfiguration.server = "https://<*HEROKU APP ID*>.herokuapp.com/parse"
    })

 Parse.initializeWithConfiguration(parseConfiguration) 

&安培;对开源解析服务器代码(https://github.com/ParsePlatform/parse-server-example)的唯一修改是替换配置以匹配我的Parse / mongo标识:

var api = new ParseServer({
  databaseURI:     'mongodb://<*UNIUQUE ID*>' || 'mongodb://localhost:27017/dev',
  cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  appId: '<*PARSE APP ID*>',
  masterKey: '<*PARSE MASTER KEY*>'
});

3 个答案:

答案 0 :(得分:9)

你需要添加包含一系列有效facebook app id的密钥facebookAppIds,文档中提到here

或者,添加FACEBOOK_APP_ID键作为引用[here](https://github.com/ParsePlatform/parse-server/issues/82

答案 1 :(得分:3)

我不知道你是否已经拥有或试过这个,但我和你的情况非常相似,为我解决了这个问题:

AppDelegate.swift 中,ParseClientConfiguration必须初始化 BEFORE didFinishLaunchingWithOptions中解析Facebook Utils初始化:

...

// *** Initialize Parse. ***
let config = ParseClientConfiguration(block: {
    (ParseMutableClientConfiguration) -> Void in
    ParseMutableClientConfiguration.applicationId = appKey;
    ParseMutableClientConfiguration.clientKey = clientKey;
    ParseMutableClientConfiguration.server = serverURL;
});

Parse.initializeWithConfiguration(config);

// *NOTE: Putting the following line after after Parse.initializeWithConfiguration(config) fixed the issue
// After this change, the user is no longer nil and does not print "Uh oh. The user cancelled the Facebook login.". Instead, it executes the `if let user = user` block
PFFacebookUtils.initializeFacebookWithApplicationLaunchOptions(launchOptions)

...

希望这对至少某人有帮助!

答案 2 :(得分:0)

我在Back4app上运行的Parse Server上遇到了同样的问题。 解决方案是在Back4app平台上添加Facebook App Id。