# Google Cloud Dialogflow V2 Client - Class ApiKeyConfig (2.4.0)

2.4.0 (latest) 2.3.1 2.2.1 2.1.2 2.0.1 1.17.2 1.16.0 1.15.1 1.14.0 1.13.0 1.12.3 1.11.0 1.10.2 1.9.0 1.8.0 1.7.2 1.6.0 1.5.0 1.4.0 1.3.2 1.2.0 1.1.1 1.0.1 Reference documentation and code samples for the Google Cloud Dialogflow V2 Client class ApiKeyConfig.

Config for authentication with API key.

Generated from protobuf message `google.cloud.dialogflow.v2.Tool.Authentication.ApiKeyConfig`

## Namespace

Google \\ Cloud \\ Dialogflow \\ V2 \\ Tool \\ Authentication

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ key_name` | `string` Required. The parameter name or the header name of the API key. E.g., If the API request is "<https://example.com/act?X-Api-Key> |
| `↳ api_key` | `string` Optional. The API key. If the `secret_version_for_api_key` field is set, this field will be ignored. |
| `↳ secret_version_for_api_key` | `string` Optional. The name of the SecretManager secret version resource storing the API key. If this field is set, the `api_key` field will be ignored. Format: `projects/{project}/secrets/{secret}/versions/{version}` |
| `↳ request_location` | `int` Required. Key location in the request. |

### getKeyName

Required. The parameter name or the header name of the API key.

E.g., If the API request is "<https://example.com/act?X-Api-Key>


| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setKeyName

Required. The parameter name or the header name of the API key.

E.g., If the API request is "<https://example.com/act?X-Api-Key>


| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getApiKey

Optional. The API key. If the `secret_version_for_api_key` field is
set, this field will be ignored.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setApiKey

Optional. The API key. If the `secret_version_for_api_key` field is
set, this field will be ignored.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getSecretVersionForApiKey

Optional. The name of the SecretManager secret version resource storing
the API key. If this field is set, the `api_key` field will be ignored.

Format: `projects/{project}/secrets/{secret}/versions/{version}`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setSecretVersionForApiKey

Optional. The name of the SecretManager secret version resource storing
the API key. If this field is set, the `api_key` field will be ignored.

Format: `projects/{project}/secrets/{secret}/versions/{version}`

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getRequestLocation

Required. Key location in the request.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` | Enum of type [RequestLocation](https://docs.cloud.google.com/php/docs/reference/cloud-dialogflow/latest/V2.Tool.Authentication.RequestLocation). |

### setRequestLocation

Required. Key location in the request.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int` Enum of type [RequestLocation](https://docs.cloud.google.com/php/docs/reference/cloud-dialogflow/latest/V2.Tool.Authentication.RequestLocation). |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |