我正在使用 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("","");
我只是从解析服务器文档中复制。
the gif when i login 有时,它会给出此日志: 呃哦。用户取消了推特登录
the gif when twitter pop up and login 它不提供任何日志。所以我认为它不起作用
最佳答案
我也遇到了同样的问题!似乎解析服务器默认没有 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"
}
}
});
关于java - 解析服务器开源 Android Twitter 登录不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38795931/