how to get email address using this scope from google plus integration

痴心易碎 提交于 2019-12-08 09:39:24

问题


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..


回答1:


You need to parse the scope like this

String SCOPE = "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile";




回答2:


Use below line to get email address using GoogleApiClient

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



回答3:


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();
    }
}



回答4:


For better understanding try http://www.androidhive.info/2014/02/android-login-with-google-plus-account-1/.



来源:https://stackoverflow.com/questions/26057215/how-to-get-email-address-using-this-scope-from-google-plus-integration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!