解析服务器开源Android Twitter登录不起作用

时间:2016-08-05 18:44:45

标签: java android twitter parse-platform

我正在使用Parse Server开发Android应用程序。现在,正常的登录系统和Facebook登录系统运行良好。但是,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("","");

我只是从解析服务器doc。

复制

the gif when i login 有时,它给出了这个日志: 哦,哦。用户取消了Twitter登录

the gif when twitter pop up and login 它没有给出任何日志。所以我认为它不起作用

1 个答案:

答案 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