簡體   English   中英

使用Facebook登錄解析服務器時出錯

[英]Error Using Facebook Login With 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*>'
});

你需要添加包含有效的Facebook應用程序ID數組的關鍵facebookAppIds,這是提到這里的文檔。

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

我不知道你是否已經擁有或試過這個,但我和你的情況非常相似,為我解決了這個問題:

AppDelegate.swift中 ,必須在didFinishLaunchingWithOptions的Parse Facebook Utils初始化之前初始化ParseClientConfiguration

...

// *** 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)

...

希望這至少對某人有幫助!

我在Back4app上運行的Parse Server上遇到了同樣的問題。 解決方案是在Back4app平台上添加Facebook App Id。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM