static { try { authCredentials = AuthCredentials.createForJson(JSON_KEY_STREAM); } catch (IOException e) { fail("Couldn't create fake JSON credentials."); } }
private static AuthCredentials defaultAuthCredentials() { // Consider App Engine. This will not be needed once issue #21 is fixed. if (appEngineAppId() != null) { try { return AuthCredentials.createForAppEngine(); } catch (Exception ignore) { // Maybe not on App Engine } } try { return AuthCredentials.createApplicationDefaults(); } catch (Exception ex) { // fallback to old-style } // Consider old-style Compute. This will not be needed once issue #21 is fixed. try { return AuthCredentials.createForComputeEngine(); } catch (Exception ignore) { // Maybe not on GCE } return AuthCredentials.noCredentials(); }
@Override public HttpTransport create() { // Consider App Engine if (appEngineAppId() != null) { try { return new UrlFetchTransport(); } catch (Exception ignore) { // Maybe not on App Engine } } // Consider Compute try { return AuthCredentials.getComputeCredential().getTransport(); } catch (Exception e) { // Maybe not on GCE } return new NetHttpTransport(); }