com.google.api.client.googleapis.services.GoogleClientRequestInitializer Java Examples

The following examples show how to use com.google.api.client.googleapis.services.GoogleClientRequestInitializer. 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 android-fido with Apache License 2.0 6 votes vote down vote up
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: CloudEndpointUtils.java    From solutions-mobile-shopping-assistant-backend-java with Apache License 2.0 6 votes vote down vote up
/**
 * 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 #3
Source File: CloudEndpointBuilderHelper.java    From solutions-mobile-shopping-assistant-android-client with Apache License 2.0 6 votes vote down vote up
/**
 * 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 #4
Source File: CloudEndpointUtils.java    From io2014-codelabs with Apache License 2.0 6 votes vote down vote up
/**
 * 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 #5
Source File: EndpointsTaskBagImpl.java    From endpoints-codelab-android with GNU General Public License v3.0 6 votes vote down vote up
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 #6
Source File: CloudEndpointBuilderHelper.java    From MobileShoppingAssistant-sample with Apache License 2.0 6 votes vote down vote up
/**
 * *
 *
 * @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 #7
Source File: MainActivity.java    From android-docs-samples with Apache License 2.0 6 votes vote down vote up
@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 #8
Source File: MainActivity.java    From android-docs-samples with Apache License 2.0 6 votes vote down vote up
@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 #9
Source File: GAEService.java    From security-samples with Apache License 2.0 6 votes vote down vote up
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 #10
Source File: AbstractGoogleJsonClient.java    From google-api-java-client with Apache License 2.0 4 votes vote down vote up
@Override
public Builder setGoogleClientRequestInitializer(
    GoogleClientRequestInitializer googleClientRequestInitializer) {
  return (Builder) super.setGoogleClientRequestInitializer(googleClientRequestInitializer);
}
 
Example #11
Source File: MockGoogleJsonClient.java    From google-api-java-client with Apache License 2.0 4 votes vote down vote up
@Override
public Builder setGoogleClientRequestInitializer(
    GoogleClientRequestInitializer googleClientRequestInitializer) {
  return (Builder) super.setGoogleClientRequestInitializer(googleClientRequestInitializer);
}
 
Example #12
Source File: MockGoogleClient.java    From google-api-java-client with Apache License 2.0 4 votes vote down vote up
@Override
public Builder setGoogleClientRequestInitializer(
    GoogleClientRequestInitializer googleClientRequestInitializer) {
  return (Builder) super.setGoogleClientRequestInitializer(googleClientRequestInitializer);
}
 
Example #13
Source File: AbstractGoogleProtoClient.java    From google-api-java-client with Apache License 2.0 4 votes vote down vote up
@Override
public Builder setGoogleClientRequestInitializer(
    GoogleClientRequestInitializer googleClientRequestInitializer) {
  return (Builder) super.setGoogleClientRequestInitializer(googleClientRequestInitializer);
}
 
Example #14
Source File: MockGoogleProtoClient.java    From google-api-java-client with Apache License 2.0 4 votes vote down vote up
@Override
public Builder setGoogleClientRequestInitializer(
    GoogleClientRequestInitializer googleClientRequestInitializer) {
  return (Builder) super.setGoogleClientRequestInitializer(googleClientRequestInitializer);
}
 
Example #15
Source File: GitHub.java    From android-oauth-client with Apache License 2.0 4 votes vote down vote up
@Override
public Builder setGoogleClientRequestInitializer(
        GoogleClientRequestInitializer googleClientRequestInitializer) {
    return (Builder) super
            .setGoogleClientRequestInitializer(googleClientRequestInitializer);
}
 
Example #16
Source File: Twitter.java    From android-oauth-client with Apache License 2.0 4 votes vote down vote up
@Override
public Builder setGoogleClientRequestInitializer(
        GoogleClientRequestInitializer googleClientRequestInitializer) {
    return (Builder) super
            .setGoogleClientRequestInitializer(googleClientRequestInitializer);
}
 
Example #17
Source File: Flickr.java    From android-oauth-client with Apache License 2.0 4 votes vote down vote up
@Override
public Builder setGoogleClientRequestInitializer(
        GoogleClientRequestInitializer googleClientRequestInitializer) {
    return (Builder) super
            .setGoogleClientRequestInitializer(googleClientRequestInitializer);
}
 
Example #18
Source File: Instagram.java    From android-oauth-client with Apache License 2.0 4 votes vote down vote up
@Override
public Builder setGoogleClientRequestInitializer(
        GoogleClientRequestInitializer googleClientRequestInitializer) {
    return (Builder) super
            .setGoogleClientRequestInitializer(googleClientRequestInitializer);
}
 
Example #19
Source File: Plurk.java    From android-oauth-client with Apache License 2.0 4 votes vote down vote up
@Override
public Builder setGoogleClientRequestInitializer(
        GoogleClientRequestInitializer googleClientRequestInitializer) {
    return (Builder) super
            .setGoogleClientRequestInitializer(googleClientRequestInitializer);
}