com.google.api.client.googleapis.services.AbstractGoogleClientRequest Java Examples
The following examples show how to use
com.google.api.client.googleapis.services.AbstractGoogleClientRequest.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GAEService.java From security-samples with Apache License 2.0 | 6 votes |
private void initFido2GAEService() { if (fido2Service != null) { return; } if (googleSignInAccount == null) { return; } GoogleAccountCredential credential = GoogleAccountCredential.usingAudience( context, "server:client_id:" + Constants.SERVER_CLIENT_ID); credential.setSelectedAccountName(googleSignInAccount.getEmail()); Log.d(TAG, "credential account name " + credential.getSelectedAccountName()); Fido2RequestHandler.Builder builder = new Fido2RequestHandler.Builder( AndroidHttp.newCompatibleTransport(), new AndroidJsonFactory(), credential) .setGoogleClientRequestInitializer( new GoogleClientRequestInitializer() { @Override public void initialize(AbstractGoogleClientRequest<?> abstractGoogleClientRequest) throws IOException { abstractGoogleClientRequest.setDisableGZipContent(true); } }); fido2Service = builder.build(); }
Example #2
Source File: GAEService.java From android-fido with Apache License 2.0 | 6 votes |
private void initFido2GAEService() { if (fido2Service != null) { return; } if (googleSignInAccount == null) { return; } GoogleAccountCredential credential = GoogleAccountCredential.usingAudience( context, "server:client_id:" + Constants.SERVER_CLIENT_ID); credential.setSelectedAccountName(googleSignInAccount.getEmail()); Log.d(TAG, "credential account name " + credential.getSelectedAccountName()); Fido2RequestHandler.Builder builder = new Fido2RequestHandler.Builder( AndroidHttp.newCompatibleTransport(), new AndroidJsonFactory(), credential) .setGoogleClientRequestInitializer( new GoogleClientRequestInitializer() { @Override public void initialize(AbstractGoogleClientRequest<?> abstractGoogleClientRequest) throws IOException { abstractGoogleClientRequest.setDisableGZipContent(true); } }); fido2Service = builder.build(); }
Example #3
Source File: CloudEndpointUtils.java From solutions-mobile-shopping-assistant-backend-java with Apache License 2.0 | 6 votes |
/** * Updates the Google client builder to connect the appropriate server based * on whether LOCAL_ANDROID_RUN is true or false. * * @param builder * Google client builder * @return same Google client builder */ public static <B extends AbstractGoogleClient.Builder> B updateBuilder( B builder) { if (LOCAL_ANDROID_RUN) { builder.setRootUrl(LOCAL_APP_ENGINE_SERVER_URL_FOR_ANDROID + "/_ah/api/"); } // only enable GZip when connecting to remote server final boolean enableGZip = builder.getRootUrl().startsWith("https:"); builder.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() { public void initialize(AbstractGoogleClientRequest<?> request) throws IOException { if (!enableGZip) { request.setDisableGZipContent(true); } } }); return builder; }
Example #4
Source File: MainActivity.java From android-docs-samples with Apache License 2.0 | 6 votes |
@Override protected String doInBackground(String... params) { if (myApiService == null) { // Only do this once MyApi.Builder builder = new MyApi.Builder(AndroidHttp.newCompatibleTransport(), new AndroidJsonFactory(), null) .setRootUrl("https://YOUR-PROJECT-ID.appspot.com/_ah/api/") .setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() { @Override public void initialize(AbstractGoogleClientRequest<?> abstractGoogleClientRequest) throws IOException { abstractGoogleClientRequest.setDisableGZipContent(true); } }); // end options for devappserver myApiService = builder.build(); } try { return myApiService.sayHi(params[0]).execute().getData(); } catch (IOException e) { return e.getMessage(); } }
Example #5
Source File: MainActivity.java From android-docs-samples with Apache License 2.0 | 6 votes |
@Override protected String doInBackground(String... params) { if (myApiService == null) { // Only do this once MyApi.Builder builder = new MyApi.Builder(AndroidHttp.newCompatibleTransport(), new AndroidJsonFactory(), null) .setRootUrl("http://YOUR-PROJECT-ID.appspot.com/_ah/api/") .setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() { @Override public void initialize(AbstractGoogleClientRequest<?> abstractGoogleClientRequest) throws IOException { abstractGoogleClientRequest.setDisableGZipContent(true); } }); // end options for devappserver myApiService = builder.build(); } try { return myApiService.sayHi(params[0]).execute().getData(); } catch (IOException e) { return e.getMessage(); } }
Example #6
Source File: CloudEndpointBuilderHelper.java From solutions-mobile-shopping-assistant-android-client with Apache License 2.0 | 6 votes |
/** * Updates the Google client builder to connect the appropriate server based on whether * LOCAL_ANDROID_RUN is true or false. * * @param builder Google client builder * @return same Google client builder */ public static <B extends AbstractGoogleClient.Builder> B updateBuilder(B builder) { if (LOCAL_ANDROID_RUN) { builder.setRootUrl(LOCAL_APP_ENGINE_SERVER_URL + "/_ah/api/"); } // only enable GZip when connecting to remote server final boolean enableGZip = builder.getRootUrl().startsWith("https:"); builder.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() { @Override public void initialize(AbstractGoogleClientRequest<?> request) { if (!enableGZip) { request.setDisableGZipContent(true); } } }); return builder; }
Example #7
Source File: GcsStorageService.java From front50 with Apache License 2.0 | 6 votes |
private <T> T timeExecute(Id timerId, AbstractGoogleClientRequest<T> request) throws IOException { T result; Clock clock = registry.clock(); long startTime = clock.monotonicTime(); int statusCode = -1; try { result = request.execute(); statusCode = request.getLastStatusCode(); } catch (HttpResponseException e) { statusCode = e.getStatusCode(); throw e; } catch (IOException ioex) { throw ioex; } catch (Exception ex) { throw new IllegalStateException(ex); } finally { long nanos = clock.monotonicTime() - startTime; String status = Integer.toString(statusCode).charAt(0) + "xx"; Id id = timerId.withTags("status", status, "statusCode", Integer.toString(statusCode)); registry.timer(id).record(nanos, TimeUnit.NANOSECONDS); } return result; }
Example #8
Source File: CloudEndpointUtils.java From io2014-codelabs with Apache License 2.0 | 6 votes |
/** * Updates the Google client builder to connect the appropriate server based * on whether LOCAL_ANDROID_RUN is true or false. * * @param builder Google client builder * @return same Google client builder */ public static <B extends AbstractGoogleClient.Builder> B updateBuilder(B builder) { if (LOCAL_ANDROID_RUN) { builder.setRootUrl(LOCAL_APP_ENGINE_SERVER_URL + "/_ah/api/"); } // only enable GZip when connecting to remote server final boolean enableGZip = builder.getRootUrl().startsWith("https:"); builder.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() { @Override public void initialize(AbstractGoogleClientRequest<?> request) throws IOException { if (!enableGZip) { request.setDisableGZipContent(true); } } }); return builder; }
Example #9
Source File: BigQueryServicesImpl.java From beam with Apache License 2.0 | 6 votes |
@VisibleForTesting static <T> T executeWithRetries( AbstractGoogleClientRequest<T> request, String errorMessage, Sleeper sleeper, BackOff backoff, SerializableFunction<IOException, Boolean> shouldRetry) throws IOException, InterruptedException { Exception lastException = null; do { try { return request.execute(); } catch (IOException e) { lastException = e; if (!shouldRetry.apply(e)) { break; } LOG.info("Ignore the error and retry the request.", e); } } while (nextBackOff(sleeper, backoff)); throw new IOException(errorMessage, lastException); }
Example #10
Source File: CloudEndpointBuilderHelper.java From MobileShoppingAssistant-sample with Apache License 2.0 | 6 votes |
/** * * * * @return ShoppingAssistant endpoints to the GAE backend. */ static ShoppingAssistant getEndpoints() { // Create API handler ShoppingAssistant.Builder builder = new ShoppingAssistant.Builder( AndroidHttp.newCompatibleTransport(), new AndroidJsonFactory(), getRequestInitializer()) .setRootUrl(Constants.ROOT_URL) .setGoogleClientRequestInitializer( new GoogleClientRequestInitializer() { @Override public void initialize( final AbstractGoogleClientRequest<?> abstractGoogleClientRequest) throws IOException { abstractGoogleClientRequest .setDisableGZipContent(true); } } ); return builder.build(); }
Example #11
Source File: EndpointsTaskBagImpl.java From endpoints-codelab-android with GNU General Public License v3.0 | 6 votes |
public EndpointsTaskBagImpl(TodoPreferences preferences, LocalTaskRepository localRepository) { super(preferences, localRepository, null); // Production testing //TaskApi.Builder builder = new TaskApi.Builder(AndroidHttp.newCompatibleTransport(), new AndroidJsonFactory(), null); // Local testing TaskApi.Builder builder = new TaskApi.Builder(AndroidHttp.newCompatibleTransport(), new AndroidJsonFactory(), null) .setRootUrl("http://10.0.2.2:8080/_ah/api/") .setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() { @Override public void initialize(AbstractGoogleClientRequest<?> abstractGoogleClientRequest) throws IOException { abstractGoogleClientRequest.setDisableGZipContent(true); } }); taskApiService = builder.build(); }
Example #12
Source File: BaseWorkflowSample.java From googleads-shopping-samples with Apache License 2.0 | 6 votes |
protected <T extends GenericJson> T retryFailures( AbstractGoogleClientRequest<T> request, BackOff backOff) throws IOException { while (true) { try { return request.execute(); } catch (GoogleJsonResponseException e) { try { long nextPause = backOff.nextBackOffMillis(); if (nextPause == BackOff.STOP) { throw e; } System.out.printf("Operation failed, retrying in %f seconds.%n", nextPause / 1000.0); BackOffUtils.next(Sleeper.DEFAULT, backOff); } catch (InterruptedException ie) { // Just go straight into retry if interrupted. } } } }
Example #13
Source File: ExampleUtils.java From deployment-examples with MIT License | 5 votes |
private static <T> T executeNullIfNotFound(AbstractGoogleClientRequest<T> request) throws IOException { try { return request.execute(); } catch (GoogleJsonResponseException e) { if (e.getStatusCode() == SC_NOT_FOUND) { return null; } else { throw e; } } }
Example #14
Source File: GoogleApiDebugOptions.java From beam with Apache License 2.0 | 5 votes |
@Override public void initialize(AbstractGoogleClientRequest<?> request) throws IOException { for (Map.Entry<String, String> entry : this.entrySet()) { if (request.getClass().getCanonicalName().contains(entry.getKey())) { request.set("$trace", entry.getValue()); } } }
Example #15
Source File: ExampleUtils.java From beam with Apache License 2.0 | 5 votes |
private static <T> T executeNullIfNotFound(AbstractGoogleClientRequest<T> request) throws IOException { try { return request.execute(); } catch (GoogleJsonResponseException e) { if (e.getStatusCode() == SC_NOT_FOUND) { return null; } else { throw e; } } }
Example #16
Source File: ClientRequestHelper.java From hadoop-connectors with Apache License 2.0 | 4 votes |
/** * Wraps AbstractGoogleClientRequest.getMediaHttpUploader(). */ public void setChunkSize( AbstractGoogleClientRequest<S> clientRequest, int chunkSize) { clientRequest.getMediaHttpUploader().setChunkSize(chunkSize); }
Example #17
Source File: ClientRequestHelper.java From hadoop-connectors with Apache License 2.0 | 4 votes |
/** * Configures the {@code clientRequest} to enable/disable direct (single-request) uploads * according to {@code enable}. */ public void setDirectUploadEnabled( AbstractGoogleClientRequest<S> clientRequest, boolean enable) { clientRequest.getMediaHttpUploader().setDirectUploadEnabled(enable); }
Example #18
Source File: ResilientOperation.java From hadoop-connectors with Apache License 2.0 | 4 votes |
private AbstractGoogleClientRequestExecutor(AbstractGoogleClientRequest<T> request) { this.request = request; }
Example #19
Source File: CommonGoogleJsonClientRequestInitializer.java From google-api-java-client with Apache License 2.0 | 4 votes |
@Override public final void initialize(AbstractGoogleClientRequest<?> request) throws IOException { super.initialize(request); initializeJsonRequest((AbstractGoogleJsonClientRequest<?>) request); }
Example #20
Source File: CommonGoogleProtoClientRequestInitializer.java From google-api-java-client with Apache License 2.0 | 4 votes |
@Override public final void initialize(AbstractGoogleClientRequest<?> request) throws IOException { super.initialize(request); initializeProtoRequest((AbstractGoogleProtoClientRequest<?>) request); }
Example #21
Source File: ClientRequestHelper.java From hadoop-connectors with Apache License 2.0 | 4 votes |
/** * Wraps AbstractGoogleClientRequest.getRequestHeaders(). */ public HttpHeaders getRequestHeaders( AbstractGoogleClientRequest<S> clientRequest) { return clientRequest.getRequestHeaders(); }
Example #22
Source File: GoogleApiDebugOptions.java From beam with Apache License 2.0 | 4 votes |
/** * Creates a {@link GoogleApiTracer} that sets the trace {@code traceDestination} on all calls * that match for the given request type. */ public GoogleApiTracer addTraceFor( AbstractGoogleClientRequest<?> request, String traceDestination) { put(request.getClass().getCanonicalName(), traceDestination); return this; }
Example #23
Source File: GitHub.java From android-oauth-client with Apache License 2.0 | 4 votes |
@Override protected void initialize(AbstractGoogleClientRequest<?> httpClientRequest) throws IOException { super.initialize(httpClientRequest); }
Example #24
Source File: Twitter.java From android-oauth-client with Apache License 2.0 | 4 votes |
@Override protected void initialize(AbstractGoogleClientRequest<?> httpClientRequest) throws IOException { super.initialize(httpClientRequest); }
Example #25
Source File: Flickr.java From android-oauth-client with Apache License 2.0 | 4 votes |
@Override protected void initialize(AbstractGoogleClientRequest<?> httpClientRequest) throws IOException { super.initialize(httpClientRequest); }
Example #26
Source File: Instagram.java From android-oauth-client with Apache License 2.0 | 4 votes |
@Override protected void initialize(AbstractGoogleClientRequest<?> httpClientRequest) throws IOException { super.initialize(httpClientRequest); }
Example #27
Source File: Plurk.java From android-oauth-client with Apache License 2.0 | 4 votes |
@Override protected void initialize(AbstractGoogleClientRequest<?> httpClientRequest) throws IOException { super.initialize(httpClientRequest); }
Example #28
Source File: GoogleApiClientUtil.java From styx with Apache License 2.0 | 4 votes |
public static <T> T executeWithRetries(AbstractGoogleClientRequest<T> request) throws IOException { return executeWithRetries(request, DEFAULT_RETRY_WAIT_STRATEGY, DEFAULT_RETRY_STOP_STRATEGY); }
Example #29
Source File: ResilientOperation.java From hadoop-connectors with Apache License 2.0 | 2 votes |
/** * Returns a {@link CheckedCallable} that encompasses a {@link AbstractGoogleClientRequest} and * can be used to retry the execution for an AbstractGoogleClientRequest. * * @param request The AbstractGoogleClientRequest to turn into a {@link CheckedCallable}. * @return a CheckedCallable object that attempts a AbstractGoogleClientRequest */ public static <V> CheckedCallable<V, IOException> getGoogleRequestCallable( AbstractGoogleClientRequest<V> request) { return new AbstractGoogleClientRequestExecutor<>(request); }