use of com.google.api.services.oauth2.Oauth2 in project google-cloud-intellij by GoogleCloudPlatform.
the class GoogleLoginUtils method getUserInfo.
/**
* Sets the user info on the callback.
*/
@SuppressWarnings("FutureReturnValueIgnored")
public static void getUserInfo(@NotNull final Credential credential, final IUserPropertyCallback<Userinfoplus> callback) {
final Oauth2 userInfoService = new Oauth2.Builder(new NetHttpTransport(), new JacksonFactory(), credential).setApplicationName(ServiceManager.getService(PluginInfoService.class).getUserAgent()).build();
ApplicationManager.getApplication().executeOnPooledThread(() -> {
Userinfoplus userInfo = null;
try {
userInfo = userInfoService.userinfo().get().execute();
} catch (IOException ex) {
// The core IDE functionality still works, so this does
// not affect anything right now. The user will receive
// error messages when they attempt to do something that
// requires a logged in state.
LOG.warn("Error retrieving user information.", ex);
}
if (userInfo != null && userInfo.getId() != null) {
callback.setProperty(userInfo);
} else {
callback.setProperty(null);
}
});
}
use of com.google.api.services.oauth2.Oauth2 in project workbench by all-of-us.
the class UserInfoService method getUserInfo.
public Userinfoplus getUserInfo(String token) throws IOException {
GoogleCredential credential = new GoogleCredential().setAccessToken(token);
Oauth2 oauth2 = new Oauth2.Builder(httpTransport, jsonFactory, credential).setApplicationName(APPLICATION_NAME).build();
return ExceptionUtils.executeWithRetries(oauth2.userinfo().get());
}
Aggregations