0
votes

I tried this URL https://www.googleapis.com/auth/userinfo.profile in android oauth, while google plus integration in my application.

Getting the following json and this json array does't contain the email address like this

profile{"displayName":"Devarajan Mahalingam","gender":"male",
"id":"101222514586833333269",
"image":{"url":"https://"}

am getting all details except email address.I need to get email address..

4
Why exactly do you need email address? How is this related to gmail-api? Seems specific to G+ API.Eric D

4 Answers

1
votes

Use below line to get email address using GoogleApiClient

    String email = Plus.AccountApi.getAccountName(mGoogleApiClient);
0
votes

Whether you Checked this ? Hope this helps.

private void getProfileInformation() {
    try {
        if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {

            Person currentPerson = Plus.PeopleApi
                    .getCurrentPerson(mGoogleApiClient);
            String email = Plus.AccountApi.getAccountName(mGoogleApiClient);
            String personName = currentPerson.getDisplayName();
            String personPhotoUrl = currentPerson.getImage().getUrl();
            String personGooglePlusProfile = currentPerson.getUrl();


            Log.e(TAG, "Name: " + personName + ", plusProfile: "
                    + personGooglePlusProfile + ", email: " + email
                    + ", Image: " + personPhotoUrl);

            txtName.setText(personName);
            txtEmail.setText(email);

            // by default the profile url gives 50x50 px image only
            // we can replace the value with whatever dimension we want by
            // replacing sz=X
            personPhotoUrl = personPhotoUrl.substring(0,
                    personPhotoUrl.length() - 2)
                    + PROFILE_PIC_SIZE;

            new LoadProfileImage(imgProfilePic).execute(personPhotoUrl);

        } else {
            Toast.makeText(getApplicationContext(),
                    "Person information is null", Toast.LENGTH_LONG).show();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}