2016-08-05 94 views
3

我正在使用Parse Server開發Android應用程序。目前,正常的登錄系統和Facebook登錄系統運行良好。但是,Twitter登錄不起作用。解析服務器開放源碼Android Twitter登錄無效

這裏是我的代碼:

twitterLogin.setOnClickListener(new View.OnClickListener() { 
    @Override 
    public void onClick(View v) { 
     ParseTwitterUtils.logIn(MainActivity.this, new LogInCallback() { 
      @Override 
      public void done(ParseUser user, ParseException err) { 
       if (user == null) { 
        Log.d("MyApp", "Uh oh. The user cancelled the Twitter login."); 
       } else if (user.isNew()) { 
        Log.d("MyApp", "User signed up and logged in through Twitter!"); 
       } else { 
        Log.d("MyApp", "User logged in through Twitter!"); 
       } 
      } 
     }); 

    } 
}); 

ParseTwitterUtils.initialize("",""); 

我剛剛從解析服務器文檔複製。

the gif when i login 有時候,它會給出這個日誌: 呃哦。用戶取消了Twitter登錄

the gif when twitter pop up and login 它不給任何日誌。所以我不認爲這是工作

+0

隱藏您的推特鍵! –

+0

done thx man :) –

+0

沒問題!你檢查了我發佈的答案嗎?如果有效,請將其標記爲「已接受的答案」。 –

回答

0

我面臨同樣的問題!似乎默認情況下,解析服務器沒有twitter集成。我正在研究它!

這裏是堆棧跟蹤我越來越:

com.parse.ParseRequest$ParseRequestException: 
at com.parse.ParseRequest.newTemporaryException(ParseRequest.java:279) 
at com.parse.ParseRESTCommand.onResponseAsync(ParseRESTCommand.java:303) 
at com.parse.ParseRESTUserCommand.onResponseAsync(ParseRESTUserCommand.java:126) 
at com.parse.ParseRequest$3.then(ParseRequest.java:137) 
at com.parse.ParseRequest$3.then(ParseRequest.java:133) 
at bolts.Task$15.run(Task.java:917) 
at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105) 
at bolts.Task.completeAfterTask(Task.java:908) 
at bolts.Task.continueWithTask(Task.java:715) 
at bolts.Task.continueWithTask(Task.java:726) 
at bolts.Task$13.then(Task.java:818) 
at bolts.Task$13.then(Task.java:806) 
at bolts.Task$15.run(Task.java:917) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(
at java.util.concurrent.ThreadPoolExecutor$Worker.run(
at java.lang.Thread.run(Thread.java:818) 

編輯: 我找到了解決辦法,在你的解析服務器,你必須配置是這樣的:

var api = new ParseServer({ 
    databaseURI: databaseUri || 'mongodb://localhost:27017/dev', 
    cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js', 
    appId: process.env.APP_ID || 'myAppId', 
    masterKey: process.env.MASTER_KEY || '', //Add your master key here. Keep it secret! 
    serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse', // Don't forget to change to https if needed 

    oauth: { 
    twitter: { 
    consumer_key: "xxx", // REQUIRED 
    consumer_secret: "xxx" // REQUIRED 
    }, 
    facebook: { 
    appIds: "xxxx" 
    } 
    } 

}); 

檢查herehere高級選項。