2016-08-05 100 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高级选项。