问题
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