[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Class CommonGoogleProtoClientRequestInitializer (2.8.1)\n\nVersion latestkeyboard_arrow_down\n\n- [2.8.1 (latest)](/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.services.protobuf.CommonGoogleProtoClientRequestInitializer)\n- [2.8.0](/java/docs/reference/google-api-client/2.8.0/com.google.api.client.googleapis.services.protobuf.CommonGoogleProtoClientRequestInitializer)\n- [2.7.2](/java/docs/reference/google-api-client/2.7.2/com.google.api.client.googleapis.services.protobuf.CommonGoogleProtoClientRequestInitializer)\n- [2.6.0](/java/docs/reference/google-api-client/2.6.0/com.google.api.client.googleapis.services.protobuf.CommonGoogleProtoClientRequestInitializer)\n- [2.5.1](/java/docs/reference/google-api-client/2.5.1/com.google.api.client.googleapis.services.protobuf.CommonGoogleProtoClientRequestInitializer)\n- [2.4.1](/java/docs/reference/google-api-client/2.4.1/com.google.api.client.googleapis.services.protobuf.CommonGoogleProtoClientRequestInitializer)\n- [2.1.2](/java/docs/reference/google-api-client/2.1.2/com.google.api.client.googleapis.services.protobuf.CommonGoogleProtoClientRequestInitializer)\n- [2.0.1](/java/docs/reference/google-api-client/2.0.1/com.google.api.client.googleapis.services.protobuf.CommonGoogleProtoClientRequestInitializer)\n- [1.35.2](/java/docs/reference/google-api-client/1.35.2/com.google.api.client.googleapis.services.protobuf.CommonGoogleProtoClientRequestInitializer)\n- [1.34.1](/java/docs/reference/google-api-client/1.34.1/com.google.api.client.googleapis.services.protobuf.CommonGoogleProtoClientRequestInitializer)\n- [1.33.4](/java/docs/reference/google-api-client/1.33.4/com.google.api.client.googleapis.services.protobuf.CommonGoogleProtoClientRequestInitializer) \n\n public class CommonGoogleProtoClientRequestInitializer extends CommonGoogleClientRequestInitializer\n\nBeta \n\nGoogle protocol buffer client request initializer implementation for setting properties like key\nand userIp.\n\nThe simplest usage is to use it to set the key parameter: \n\n\n public static final GoogleClientRequestInitializer KEY_INITIALIZER =\n new CommonGoogleProtoClientRequestInitializer(KEY);\n \nThere is also a constructor to set both the key and userIp parameters: \n\n\n public static final GoogleClientRequestInitializer INITIALIZER =\n new CommonGoogleProtoClientRequestInitializer(KEY, USER_IP);\n \nIf you want to implement custom logic, extend it like this: \n\n\n public static class MyRequestInitializer extends CommonGoogleProtoClientRequestInitializer {\n\n {@literal @}Override\n public void initialize(AbstractGoogleProtoClientRequest{@literal \u003c}?{@literal\u003e} request)\n throws IOException {\n // custom logic\n }\n }\n \nFinally, to set the key and userIp parameters and insert custom logic, extend it like this: \n\n\n public static class MyKeyRequestInitializer extends CommonGoogleProtoClientRequestInitializer {\n\n public MyKeyRequestInitializer() {\n super(KEY, USER_IP);\n }\n\n {@literal @}Override\n public void initializeProtoRequest(\n AbstractGoogleProtoClientRequest{@literal \u003c}?{@literal\u003e} request) throws IOException {\n // custom logic\n }\n }\n \nSubclasses should be thread-safe. \n\nInheritance\n-----------\n\n[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \\\u003e [CommonGoogleClientRequestInitializer](/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.services.CommonGoogleClientRequestInitializer) \\\u003e CommonGoogleProtoClientRequestInitializer \n\nInherited Members\n-----------------\n\n[CommonGoogleClientRequestInitializer.getKey()](/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.services.CommonGoogleClientRequestInitializer#com_google_api_client_googleapis_services_CommonGoogleClientRequestInitializer_getKey__) \n[CommonGoogleClientRequestInitializer.getRequestReason()](/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.services.CommonGoogleClientRequestInitializer#com_google_api_client_googleapis_services_CommonGoogleClientRequestInitializer_getRequestReason__) \n[CommonGoogleClientRequestInitializer.getUserAgent()](/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.services.CommonGoogleClientRequestInitializer#com_google_api_client_googleapis_services_CommonGoogleClientRequestInitializer_getUserAgent__) \n[CommonGoogleClientRequestInitializer.getUserIp()](/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.services.CommonGoogleClientRequestInitializer#com_google_api_client_googleapis_services_CommonGoogleClientRequestInitializer_getUserIp__) \n[CommonGoogleClientRequestInitializer.getUserProject()](/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.services.CommonGoogleClientRequestInitializer#com_google_api_client_googleapis_services_CommonGoogleClientRequestInitializer_getUserProject__) \n[CommonGoogleClientRequestInitializer.initialize(AbstractGoogleClientRequest\\\u003c?\\\u003e)](/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.services.CommonGoogleClientRequestInitializer#com_google_api_client_googleapis_services_CommonGoogleClientRequestInitializer_initialize_com_google_api_client_googleapis_services_AbstractGoogleClientRequest____) \n[CommonGoogleClientRequestInitializer.newBuilder()](/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.services.CommonGoogleClientRequestInitializer#com_google_api_client_googleapis_services_CommonGoogleClientRequestInitializer_newBuilder__) \n[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) \n[Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) \n[Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) \n[Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) \n[Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) \n[Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) \n[Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) \n[Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) \n[Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) \n[Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)\n\nConstructors\n------------\n\n### CommonGoogleProtoClientRequestInitializer()\n\n public CommonGoogleProtoClientRequestInitializer()\n\n### CommonGoogleProtoClientRequestInitializer(String key)\n\n public CommonGoogleProtoClientRequestInitializer(String key)\n\n### CommonGoogleProtoClientRequestInitializer(String key, String userIp)\n\n public CommonGoogleProtoClientRequestInitializer(String key, String userIp)\n\nMethods\n-------\n\n### initialize(AbstractGoogleClientRequest\\\u003c?\\\u003e request)\n\n public final void initialize(AbstractGoogleClientRequest\u003c?\u003e request)\n\nSubclasses should call super implementation in order to set the key and userIp.\n\n**Overrides** \n[CommonGoogleClientRequestInitializer.initialize(AbstractGoogleClientRequest\\\u003c?\\\u003e request)](/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.services.CommonGoogleClientRequestInitializer#com_google_api_client_googleapis_services_CommonGoogleClientRequestInitializer_initialize_com_google_api_client_googleapis_services_AbstractGoogleClientRequest____)\n\n### initializeProtoRequest(AbstractGoogleProtoClientRequest\\\u003c?\\\u003e request)\n\n protected void initializeProtoRequest(AbstractGoogleProtoClientRequest\u003c?\u003e request)\n\nInitializes a Google protocol buffer client request.\n\nDefault implementation does nothing. Called from [#initialize(AbstractGoogleClientRequest)](/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.services.protobuf.CommonGoogleProtoClientRequestInitializer#com_google_api_client_googleapis_services_protobuf_CommonGoogleProtoClientRequestInitializer_initialize_com_google_api_client_googleapis_services_AbstractGoogleClientRequest____)."]]