Java 解析Google plus登录
我使用的是Parse,用户可以在那里使用Facebook、Twitter和Google+登录。到目前为止,只有Facebook和Twitter功能齐全 我已通过以下方式使用Facebook和Twitter登录:Java 解析Google plus登录,java,android,android-layout,android-activity,parse-platform,Java,Android,Android Layout,Android Activity,Parse Platform,我使用的是Parse,用户可以在那里使用Facebook、Twitter和Google+登录。到目前为止,只有Facebook和Twitter功能齐全 我已通过以下方式使用Facebook和Twitter登录: private void onLoginButtonClicked() { LoginActivity.this.progressDialog = ProgressDialog.show( LoginActivity.this, "", "
private void onLoginButtonClicked() {
LoginActivity.this.progressDialog = ProgressDialog.show(
LoginActivity.this, "", "Logging in...", true);
List<String> permissions = Arrays.asList("public_profile", "user_about_me",
"user_relationships", "user_birthday", "user_location");
ParseFacebookUtils.logIn(permissions, this, new LogInCallback() {
@Override
public void done(ParseUser user, ParseException err) {
LoginActivity.this.progressDialog.dismiss();
if (user == null) {
Log.d(IntegratingFacebookTutorialApplication.TAG,
"Uh oh. The user cancelled the Facebook login.");
} else if (user.isNew()) {
Log.d(IntegratingFacebookTutorialApplication.TAG,
"User signed up and logged in through Facebook!");
showUserDetailsActivity();
} else {
Log.d(IntegratingFacebookTutorialApplication.TAG,
"User logged in through Facebook!");
moodpage();
}
}
});
}
private void onTwitterButtonClicked() {
ParseTwitterUtils.logIn(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!");
showUserDetailsActivity();
} else {
Log.d("MyApp", "User logged in through Twitter!");
moodpage(); }
}
});
}
private void onLoginButtonClicked(){
LoginActivity.this.progressDialog=progressDialog.show(
LoginActivity.this,“,”登录…,”true);
List permissions=Arrays.asList(“public\u profile”、“user\u about\u me”,
“用户关系”、“用户生日”、“用户位置”);
logIn(权限,这个,新的LogInCallback(){
@凌驾
公共无效完成(ParseUser用户,ParseException错误){
LoginActivity.this.progressDialog.disclose();
if(user==null){
Log.d(IntegratingFacebookTutorialApplication.TAG、,
“哦,用户取消了Facebook登录。”);
}else if(user.isNew()){
Log.d(IntegratingFacebookTutorialApplication.TAG、,
“用户注册并通过Facebook登录!”);
showUserDetailsActivity();
}否则{
Log.d(IntegratingFacebookTutorialApplication.TAG、,
“用户通过Facebook登录!”);
moodpage();
}
}
});
}
私有void onTwitterButtonClicked(){
logIn(这是新的LogInCallback(){
@凌驾
公共无效完成(ParseUser用户,ParseException错误){
if(user==null){
Log.d(“MyApp”,“哦,用户取消了Twitter登录。”);
}else if(user.isNew()){
Log.d(“MyApp”,“用户注册并通过Twitter登录!”);
showUserDetailsActivity();
}否则{
Log.d(“MyApp”,“用户通过Twitter登录!”);
moodpage();}
}
});
}
我正试图通过解析,用Google+实现这一点。有人建议我研究一下解析RESTAPI,但是,我不熟悉它,需要更多的指导
如有任何澄清,将不胜感激。根据以下内容:
这是:
以及我对它们的理解
在使用Google+/Github/任何东西成功登录后,您只需在应用程序或云/后端中使用某种算法生成密码
simeple实现(但在应用程序中使用它并不安全):
此解决方案有一点很重要:
仅根据应用程序中的id使用id/密码是不安全的,更好的解决方案是将Google+令牌/用户id发送到后端/云,然后后端/云验证该令牌/id是否有效,然后从中创建用户名/密码并与解析用户交换
希望您能理解。是解析API文档,也是Android指南。你至少试过用谷歌搜索它吗?@user3907211还有其他的java库可以帮助Google+登录。你感兴趣吗?我会感兴趣的。有很多方法可以做到这一点,但我想在parse中创建一个关系,parse在其中存储用户登录google+的信息。@user3907211 Bozho这里排名较高的人之一编写了这个客户端库:非常感谢。我是个新手,我该如何使用API?如何发送Google+令牌??如何创建与会话令牌关联的新用户帐户?
// given Google Plus login (Using their Api) i.e. no Parse yet at this point
int id = 12345; // assume that this is google+ id (After successfully logging in)
ParseUser user = new ParseUser();
user.setUsername("google-plus-" + String.valueOf(id));
user.setPassword(hashMyPassword(id)); // Create password based on the id
user.setEmail("email.from.google.plus.login@gmail.com");
user.signUpInBackground(new SignUpCallback() {
public void done(ParseException e) {
if (e == null) {
// Hooray! Let them use the app now.
} else {
// Sign up didn't succeed. Look at the ParseException
// to figure out what went wrong
}
}
});