@Override public Optional<AccessToken> get() { Optional<AccessToken> tokenOpt = Optional.absent(); if (enabled) { if (staticToken != null) { tokenOpt = Optional.of(staticToken); } else { try { synchronized (lock) { if (credentials == null) { credentials = getCredentialsWithScopes(tokenScopes); } credentials.refreshIfExpired(); } tokenOpt = Optional.of(credentials.getAccessToken()); } catch (IOException | RuntimeException e) { LOG.debug("Exception (possibly benign) while loading Google Credentials", e); return Optional.absent(); } } } return tokenOpt; }
public GoogleCredentials getFirebaseCredentials() { try { if (firebaseCredentials == null) { try { firebaseCredentials = GoogleCredentials.fromStream( new ByteArrayInputStream(firebase.toString().getBytes("utf-8"))) .createScoped(FIREBASE_SCOPES); } catch (UnsupportedEncodingException e) { // Should never happen. } } firebaseCredentials.refreshIfExpired(); } catch (IOException e) { throw new RuntimeException("Should never happen.", e); } return firebaseCredentials; }
this.sourceCredentials.refreshIfExpired(); } catch (IOException e) { throw new IOException("Unable to refresh sourceCredentials", e);
this.sourceCredentials.refreshIfExpired(); } catch (IOException e) { throw new IOException("Unable to refresh sourceCredentials", e);