2.9.3 (latest) 2.9.2 2.8.1 2.7.2 2.6.0 2.5.1 2.4.1 2.1.2 2.0.1 1.35.2 1.34.1 1.33.4

```java
public class CommonGoogleClientRequestInitializer implements GoogleClientRequestInitializer
```
Google common client request initializer implementation for setting properties like key and
userIp.

The simplest usage is to use it to set the key parameter:

```java

 public static final GoogleClientRequestInitializer KEY_INITIALIZER =
        CommonGoogleClientRequestInitializer.newBuilder()
              .setKey(KEY)
              .build();
 
```

There is also a constructor to set both the key and userIp parameters:

```java

 public static final GoogleClientRequestInitializer INITIALIZER =
 CommonGoogleClientRequestInitializer.newBuilder()
 .setKey(KEY)
 .setUserIp(USER_IP)
 .build();
 
```

If you want to implement custom logic, extend it like this:

```java

 public static class MyRequestInitializer extends CommonGoogleClientRequestInitializer {

   {@literal @}Override
   public void initialize
       (AbstractGoogleClientRequest{@literal <}?{@literal>} request) throws IOException {
     // custom logic
   }
 }
 
```

Finally, to set the key and userIp parameters and insert custom logic, extend it like this:

```java

 public static class MyRequestInitializer2 extends CommonGoogleClientRequestInitializer {

   public MyRequestInitializer2() {
     super(KEY, USER_IP);
   }

   {@literal @}Override
   public void initialize
       (AbstractGoogleClientRequest{@literal <}?{@literal>} request) throws IOException {
     super.initialize(request); // must be called to set the key and userIp parameters
     // insert some additional logic
   }
 }
 
```

Subclasses should be thread-safe.

## Inheritance

[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> CommonGoogleClientRequestInitializer

## Implements

[GoogleClientRequestInitializer](https://docs.cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.services.GoogleClientRequestInitializer.md.txt)

## Inherited Members

[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

## Static Methods

### newBuilder()

```java
public static CommonGoogleClientRequestInitializer.Builder newBuilder()
```
Returns new builder.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `CommonGoogleClientRequestInitializer.Builder` |   |

## Constructors

### CommonGoogleClientRequestInitializer() (deprecated)

```java
public CommonGoogleClientRequestInitializer()
```
**Deprecated.** *Please use the builder interface*

### CommonGoogleClientRequestInitializer(CommonGoogleClientRequestInitializer.Builder builder)

```java
protected CommonGoogleClientRequestInitializer(CommonGoogleClientRequestInitializer.Builder builder)
```

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `builder` | `CommonGoogleClientRequestInitializer.Builder` |

### CommonGoogleClientRequestInitializer(String key) (deprecated)

```java
public CommonGoogleClientRequestInitializer(String key)
```
**Deprecated.** *Please use the builder interface*

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `key` | `String` API key or `null` to leave it unchanged |

### CommonGoogleClientRequestInitializer(String key, String userIp) (deprecated)

```java
public CommonGoogleClientRequestInitializer(String key, String userIp)
```
**Deprecated.** *Please use the builder interface*

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `key` | `String` API key or `null` to leave it unchanged |
| `userIp` | `String` user IP or `null` to leave it unchanged |

## Methods

### getKey()

```java
public final String getKey()
```
Returns the API key or `null` to leave it unchanged.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `String` |   |

### getRequestReason()

```java
public final String getRequestReason()
```
Returns the request reason or `null` to leave it unchanged.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `String` |   |

### getUserAgent()

```java
public final String getUserAgent()
```
Returns the user agent or `null` to leave it unchanged.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `String` |   |

### getUserIp()

```java
public final String getUserIp()
```
Returns the user IP or `null` to leave it unchanged.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `String` |   |

### getUserProject()

```java
public final String getUserProject()
```
Returns the user project or `null`.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `String` |   |

### initialize(AbstractGoogleClientRequest\<?\> request)

```java
public void initialize(AbstractGoogleClientRequest<?> request)
```
Subclasses should call super implementation in order to set the key and userIp.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `AbstractGoogleClientRequest<?>` |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `IOException` | I/O exception |