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?
There's a question about this on Parse's questions. It's right here and I'm pretty sure it answers your questions.
https://parse.com/questions/google-plus
It links to the parse blog, that has some workarounds on this.
It says that you can add any login into ParseUser. You would be doing something like this:
Another site where you should take a look: https://parse.com/tutorials/adding-third-party-authentication-to-your-web-app
This last one is official and has an example code
To do so, I have used the following code
Let me know if it helps or if you have used something else.
This seems to be similar with How to create a parse _User account from a Android Google token?
Following is my answer in that thread:
1. New User
The flow is as below:
You can create a ParseUser using following code inside the
newChooseAccountIntent()
method that return email.2. Returning User
This is the where most of people stuck, as I researched over the Internet. The flow is as below:
Parse.Cloud.useMasterKey()
method and return the session key by usinggetSessionToken()
method on the query result.becomeInBackground
methodTo validate the token, you can send
Parse.Cloud.httprequest
to this endpoint:https://www.googleapis.com/oauth2/v3/tokeninfo?access_token=
. This is instructed in Google Identity Documentation. You will receive data as below:Things need to compare are "aud", "azp" and "email" which are translated as audience, authorized party and email.
To query for the current user on Cloud Code:
Note: Make sure you have following scope so that the email will show up when you check on Cloud Code:
https://www.googleapis.com/auth/plus.profile.emails.read
Try this
})