java - Google OAuth2 API v2 userinfo always returns null for email -
i'm trying authenticated user's email addresses.
i've done authentication scopes
email profile https://www.googleapis.com/auth/plus.login https://www.googleapis.com/plus/v1/people/me https://www.googleapis.com/auth/userinfo.email this call returns null email name, link, picture, etc populated:
userinfoplus userinfo2 = oauth2.userinfo().v2().me().get().execute(); log.info(userinfo2.tostring()); outputs:
{ "family_name" : "homlish", "gender" : "male", "given_name" : "paul", "id" : "107004799409225320539", "link" : "https://plus.google.com/107004799409225320539", "locale" : "en", "name" : "paul homlish", "picture" : "https://lh4.googleusercontent.com/-bcrlxuqr__e/aaaaaaaaaai/aaaaaaaabr8/lqcliyz_jgi/photo.jpg" } inspecting can see email field, null.
any ideas missing?
although scopes using don't prompt user permissions, there scopes can delete not needed?
thanks, paul
by setting scope 'email', authenticating, , using com.google.api.client.googleapis.auth.oauth2.googlecredential , com.google.api.services.oauth2.oauth2 able receive email:
googlecredential credential = new googlecredential().setaccesstoken(tokenfromauthentication); oauth2 oauth2 = new oauth2.builder(new nethttptransport(), new jacksonfactory(), credential) .setapplicationname("oauth2") .build(); userinfoplus userinfo = oauth2.userinfo().get().execute();
Comments
Post a Comment