GoogleCloudPlatform / ide-login

The plugins-login-common library for authenticating with the Google Cloud Platform shared by several IDE plugins including Google Cloud Tools for Eclipse, Google Cloud Tools for IntelliJ, and Android Studio.
Apache License 2.0
2 stars 9 forks source link

Fetch/save/load account name and avatar URL #32

Closed chanseokoh closed 7 years ago

chanseokoh commented 7 years ago

Fixes #24.

Account name and avatar URL are queried through Google OAuth2 API. Basically, you do

Oauth2 oAuth2 = Oauth2.Builder(...).build();
Userinfoplus userInfo = oAuth2.userinfo().get().execute();

and the result userInfo contains an email, an account name, and an avatar URL. Very convenient.

(userInfo already contains an email, so the previous low-level logic to directly accessing https://www.googleapis.com/userinfo/email and manually parsing the response is no longer necessary.)

Notes:

chanseokoh commented 7 years ago

Also, account name and avatar URL are persisted.

elharo commented 7 years ago

Is this still active? If so, please merge with master and ping me to review. Otherwise, close. Thanks.

chanseokoh commented 7 years ago

This is active but has never been a priority. Hope I'll get back to this sooner or later.

codecov-io commented 7 years ago

Codecov Report

Merging #32 into master will increase coverage by -3.21%.

@@            Coverage Diff             @@
##           master      #32      +/-   ##
==========================================
- Coverage   78.09%   74.88%   -3.21%     
==========================================
  Files           8       10       +2     
  Lines         210      223      +13     
  Branches       24       20       -4     
==========================================
+ Hits          164      167       +3     
- Misses         38       50      +12     
+ Partials        8        6       -2
Impacted Files Coverage Δ
...in/GoogleAuthorizationCodeTokenRequestCreator.java 0% <ø> (ø) :white_check_mark:
.../google/cloud/tools/ide/login/UserInfoService.java 0% <ø> (ø)
...ava/com/google/cloud/tools/ide/login/UserInfo.java 0% <ø> (ø)
...va/com/google/cloud/tools/ide/login/OAuthData.java 100% <100%> (ø) :white_check_mark:
...om/google/cloud/tools/ide/login/AccountRoster.java 100% <100%> (ø) :white_check_mark:
.../tools/ide/login/JavaPreferenceOAuthDataStore.java 85.41% <100%> (+1.32%) :white_check_mark:
...java/com/google/cloud/tools/ide/login/Account.java 94.73% <100%> (+12.38%) :white_check_mark:
...google/cloud/tools/ide/login/GoogleLoginState.java 70.87% <88.23%> (+0.18%) :white_check_mark:
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update aa815ff...1fb2af7. Read the comment docs.

chanseokoh commented 7 years ago

Ready for review, @elharo.