如何链接谷歌+在Android上解析后端用户签订的? [英] How to link Google + signed in users on Parse backend on Android?

查看:284
本文介绍了如何链接谷歌+在Android上解析后端用户签订的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用解析3个月在我的Andr​​oid应用程序。现在我想在应用程序中添加电子邮件登录和社会的标志附件(Facebook和Google+的)。我已成功将电子邮件和fb的登录和用户可以连接两个或任一个电子邮件或Facebook和应用程序将识别用户。

例如。如果我通过电子邮件登录,然后连接脸谱,用在其他设备上,登录应用程序通过Facebook,应用程序就知道它是相同的用户,并会为用户定制了我,并会显示我的数据。而电子邮件也适用。

我已经加入 Google+登录功能对于Android 但我无法连接用户的Google+信息凭据登录的用户。

解析用户表具有的authData字段,获取Facebook的身份验证数据,并会得到微博,以及这两个标志附件的烘烤成解析软件开发工具包。

应该是什么做对Google+的最好的事情?我感到困惑的数据库设计以及如何连接谁签署的谷歌用户+?

如果用户通过Google+的只是记录在哪?我如何做一个分析用户和解析验证用户身份?

我很舒服云code和Android真的AP preciate某种帮助/指示只是把我推在正确的方向。我从来没有使用OAuth2和解析登录电子邮件和社交登录插件,我不认为我应该进入它。但是,让我知道,如果我错了。

谢谢!

更新:我已经阅读了很多关于解析问题的问题,并已签出了成为方法很多次(因为我一直在读书,经过思考,我失去了一些东西)。 检查这个问题 - 目前,我在同样的情况

我:
1.实施Google+的登录。照片 2.得到的访问令牌使用GoogltAuthUtil。

套牢:
3,如何分析用户链接当前登录的用户登录后,在Google+的?
4.如何创建一个新的分析用户如果是Google+的用户第一次(也是唯一一个)登录的选择呢?

解决方案

 无效createNewGPlusUser(最后弦乐电子邮件,字符串名称){
        最终ParseUser用户=新ParseUser();
        user.setUsername(电子邮件);
        user.setPassword(我的通行证);
        user.put(价值,用户级的其他变量);
        user.setEmail(电子邮件);
        user.put(姓名,名);
        signInParseUser(用户,电子邮件);
    }

无效signInParseUser(最终ParseUser用户,最后弦乐电子邮件){

        user.signUpInBackground(新SignUpCallback(){
            公共无效完成(ParseException的E){
                如果(E == NULL){
                    Log.d(TAG,创建用户);
                    //万岁!让他们现在使用的应用程序。
                    登录(电子邮件);
                } 其他 {
                    Log.d(TAG,无法创建用户);
                    e.printStackTrace();
                    //注册没有成功。看ParseException的
                    //找出什么地方出了错
                }
            }
        });
    }

无效的登录(最后弦乐电子邮件){
        ParseUser.logInInBackground(电子邮件,我的通行证,新LogInCallback(){
            公共无效完成(ParseUser用户,ParseException的E){
                如果(用户!= NULL){
                    //万岁!该用户已登录。
                    Log.d(TAG,登录成功);
                                    } 其他 {
                                        //注册失败。看ParseException的,看看发生了什么事。
                }
            }
        });
    }
 

I've been using Parse for 3 months in my android app. Now I want to add email login and social sign ons (Facebook and Google+) in the app. I have successfully added email and fb login and the user can connect both or either one of email or facebook and the app would recognise the user.

e.g. If I login through email, then connect facebook, use the app on another device, login via facebook, the app would know it's the same user and would be customised for me and would show my data. And email also works.

I have added Google+ sign-in for Android but I am not able to connect the user's Google+ credentials with the logged in user.

Parse Users table has an authData field which gets the facebook auth data and would get Twitter as well as both of these sign ons are baked into Parse SDKs.

What should be the best thing to do for Google+? I'm confused about the db design as well as how to connect the user who signed in with Google+?

What if the user just logs in via Google+? How do I make a Parse User and authenticate the user on Parse?

I'm comfortable with cloud code and Android and would really appreciate some sort of help/instructions just pushing me in the correct direction. I have never used OAuth2 and with Parse login for email and Social Sign ons, I don't think I should get into it. But let me know if I'm wrong.

Thanks!

Update: I have read a lot of questions on Parse Questions and have checked out the become method plenty of times (because I kept thinking I'm missing something after reading that). Check this question - I'm currently in the same situation.

I have:
1. Implemented Google+ sign in.
2. Got access token using GoogltAuthUtil.

Stuck with:
3. How to link currently signed in Parse user after the user signs in with Google+?
4. How to create a new Parse User if Google+ was the user's first (and only ) login choice?

解决方案

void createNewGPlusUser(final String email, String name) {
        final ParseUser user = new ParseUser();
        user.setUsername(email);
        user.setPassword("my pass");
        user.put("any other variable in User class", "value");
        user.setEmail(email);
        user.put("name", name);
        signInParseUser(user, email);
    }

void signInParseUser(final ParseUser user, final String email) {

        user.signUpInBackground(new SignUpCallback() {
            public void done(ParseException e) {
                if (e == null) {
                    Log.d("TAG", "Created user");
                    // Hooray! Let them use the app now.
                    login(email);
                } else {
                    Log.d("TAG", "Failed Creating user");
                    e.printStackTrace();
                    // Sign up didn't succeed. Look at the ParseException
                    // to figure out what went wrong
                }
            }
        });
    }

void login(final String email) {
        ParseUser.logInInBackground(email, "my pass", new LogInCallback() {
            public void done(ParseUser user, ParseException e) {
                if (user != null) {
                    // Hooray! The user is logged in.
                    Log.d("TAG", "Login successful");
                                    } else {
                                        // Signup failed. Look at the ParseException to see what happened.
                }
            }
        });
    }

这篇关于如何链接谷歌+在Android上解析后端用户签订的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆