How can I get user info from a google account? - android

I want to allow my app users to log on/register with a google account. I need to retrieve the following about a user
A unique id, first name, last name, email
Is it possible in android or do I have to use one of goooles services like picasa api to get this information about a user?

Login with Google+
https://developers.google.com/+/mobile/android/sign-in
Retrieve profile info
https://developers.google.com/+/mobile/android/people

Related

Can flutter firebase auth tackle multiple social media accounts with same email id?

Does firebase auth help tackle same email id account issue?
For ex. say I am using firebase auth in my flutter app. I have Facebook and Gmail of same email. 1st I create account with Gmail, logout and then 2nd time I try to create account with facebook which has same email ID. Then is firebase designed to give me some type of error message saying "user with this email has already logged in with gmail" and vice-versa ?
Thanks in advance
You can configure whether users can create multiple accounts that use the same email address, but are linked to different sign-in methods. For example, if you don't allow multiple accounts with the same email address, a user cannot create a new account that signs in using a Google Account with the email address ex#gmail.com if there already is an account that signs in using the email address ex#gmail.com and a password.
Please find the details here.
No, Firebase won't throw any error, instead it will create a new account for the second sign-in provider. As Both Sign-In providers are different i.e one is facebook and other is google in your example.
If you really want to create a single account for multiple providers.Then you will need to link multiple providers to an single account.
Checkout Firebase official documentation for the instructions to achieve this on android:-
Firebase Docs

Sigin my app with Google Account in Android

I have learned that there are many ways to sign in app with Google Account.
Here are two ways:
Use AccountManager.java ,
GOOD: can get user's email address and authToken.
BAD: can not get user's avatar and nickname.
Use Google+ Api:
GOOD: can get user's all info , but email address.
BAD: no email address, and the view's style is not matching to my app.
QUESTION:
1 .How can i get avatar and nickname by using only AccountManager ?
Is the Google+ Api's view be changed ? Any documents?
Thanks for any help!
You can get the Email address via the Google+ API. You need to add the appropriate scopes and permission.
The scopes are
Scopes.PROFILE
Scopes.EMAIL
And you need the following permission
android.permission.GET_ACCOUNTS
Then you can retrieve the Email address with the AccountApi
Plus.AccountApi.getAccountName(googleApiClient)
You can reference this guide from google doc.
After signin, handle result then get user information.

Getting google username from userid

I use Android market api
in order to fetch information from google playstore. The api returns a user id corresponding to each reviewer for an application. Sample user id's returned by the api would look like this:
cid-lg:AOqpTOGMFCTbFodkU6yTr_DttkugfrgfI0-q6a008jeD67cKE1xoDv_bT8gjjILcPcxOOZ0m3atfEDl9O0RLiYM
cid-gp:AOqpTOGCrH6yXqvnrDmTZ6C1gJrLBYioEemkZq4nflx-e1c7Eg6coh1c8q_mhtJB07-fUBps0a-AxTHMBLuDOGA
cid-gp:AOqpTOHUIW7EByEinUUKXzZeHRKC3UvbAXnGtuaVE2i4rIUXMw-zfD3WsXr4Hl25fCPSKx4ix6GXT-gt9NM_9P0
These are the user id's for 3 different reviewers for a single application.
Is there a way out by which I can get the google username corresponding to these user id's ?

Google+ Api - get associated account in android

I'm using the new Google+ Sign-in api. Once a user clicks sign in they can choose which google account to use, and then proceed to authorize the app. How can I get the account which they picked?
Reason being is I have been using regular google auth for my app and the users account is tied to the email address. With this Google+, I'm not sure how to get the account email without asking the user to selected the account again.
You can retrieve the user's profile information by using the PlusClient.loadPerson() method, which can include their email address if they choose to make it public. To reliably get their email address, you would use either the PlusClient.getAccountName() or use the userinfo REST endpoint after requesting the userinfo.email scope.
The code examples in the documentation walk through each of the above cases.

Find user's Facebook Friends that also use my Android App?

My app has an instant messaging feature. So it has a contact list.. I want to populate the contact list to help get my user started with some friends..
After asking permission I will:
1) Search the local contact database, send the phone numbers to my server and check for other accounts using my application that have the same phone number.
2) Ask them if they want to also import their facebook friends. At which point I suppose I will ask them for their username and password for facebook, log in to the Graph API and request their list of friends..
My question is, once I am iterating the list of friends from my user's facebook friends list, how can I link their facebook friend ID (or whatever identifier Facebook gives me) to some other ID in my app?
Will I see the email of all my friends users (after research, it looks like not)? Will I just get a numeric Facebook ID? If so, then how am I to harvest facebook IDs from all my users that have linked their account to facebook in my app?
I suspect this feature has been implement by other third party developers. So I'm looking for the strategy to identify and link my app users, to facebook accounts, and then iterate my app users friends list to find common users.
The question I am answering from a user perspective "Which of my facebook friends are already using this app, named XYZ on android"
You can store a user's Facebook ID alongside their other user information for your app, then match on the retrieved IDs from a Graph API /friends call. This way, you'll be able to see which friends have also linked the app to their Facebook account. You won't be able to fetch email addresses for a user's friends using the API.

Categories

Resources