2016-04-03 38 views
0

我剛剛完成了電影我的應用程序到解析服務器。除了我的Twitter登錄和註冊外,我已經完成了所有工作。當我登錄或註冊時,我收到打印到我的控制檯的內部服務器錯誤消息。我正在使用最新的Parse SDK。這裏是我的登錄代碼(我的註冊代碼是相似的,它只是會從Twitter的API等數據,並將其存儲到我的數據庫):ParseTwitterUtils內部服務器錯誤

PFTwitterUtils.logInWithBlock { 
      (user: PFUser?, error: NSError?) -> Void in 

      if let user = user { 

       if user.isNew { 

        spinningActivity.hideAnimated(true) 

        PFUser.currentUser()?.deleteInBackground() 

        self.displayNoticeWithTwoActions("Account Not Found", message: "This Twitter account is not in our system. You have to sign up first.", firstButtonTitle: "Sign Up", closeButtonTitle: "Ok", segue: "dontHaveAccountSegue") 


       } else if error != nil { 

        spinningActivity.hideAnimated(true) 

        self.displayError("Error", message: error!.localizedDescription) 

       } else { 

        spinningActivity.hideAnimated(true) 
        self.performSegueWithIdentifier("successfulLoginSegue", sender: self) 

       } 


      } else { 

       spinningActivity.hideAnimated(true) 


       self.displayError("Error", message: "Unless you tapped on 'Cancel' or 'Done', something went wrong. Please try again.") 

      } 
     } 

我能在網上找到的唯一的事情是,它可能是一個問題在推特的最後......我確信我的消費者密鑰和祕密在我的AppDelegate中是正確的。有任何想法嗎?

+0

你必須到你的Twitter身份驗證密鑰添加到您的解析服務器的配置文件 – pbush25

+0

在我情況下,我在Heroku上使用Parse Server。這是否意味着我會將一個密鑰TWITTER_AUTH添加到密鑰列表中?建議我將我的Facebook密鑰添加到列表中嗎? Facebook登錄和註冊在沒有服務器上列出的密鑰的情況下工作。我感謝您的幫助! –

回答

2

要將index.js文件是解析服務器的配置文件,你需要補充一點:

var api = new ParseServer ({ 
    databaseURI: xxxxxxx, 
    cloud: xxxxxx, 
    appID: xxxxxx, 
    //more keys 
    //add oauth keys 
    oauth: { 
     facebook: { 
      appIds: xxxxxxxxxxxxx 
     }, 
     twitter: { 
      appIds: xxxxxxxxxxxxx 
     } 
    } 
}) 
+0

我沒有index.js文件,因爲我在Heroku上託管服務器。但是,我可以選擇在Heroku中添加密鑰。你知道Facebook和Twitter的關鍵名字是什麼嗎?我只是做「鑰匙」= Facebook和「價值」= appId以及「鑰匙」= Twitter和「價值」= consumerKey? –

+0

您可以使用他們的命令行工具從Heroku中克隆您的項目,修改index.js文件,然後將更改推回到Heroku。 – pbush25

+0

查看這裏的鏈接:https://devcenter.heroku.com/articles/heroku-command和這裏:https://devcenter.heroku.com/articles/getting-started-with-nodejs#push-local-changes – pbush25