# Authorization

Authorization type for an API Destination Connection.

- Source: [`aws-events/lib/connection.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-events/lib/connection.ts#L61)
- Type last changed: v2.13.0 · 19 Feb 2022

## Example

```ts
const connection = new events.Connection(this, 'Connection', {
  authorization: events.Authorization.apiKey('x-api-key', SecretValue.secretsManager('ApiSecretName')),
  description: 'Connection with API Key x-api-key',
});

const destination = new events.ApiDestination(this, 'Destination', {
  connection,
  endpoint: 'https://example.com',
  description: 'Calling example.com with API key x-api-key',
});

const rule = new events.Rule(this, 'Rule', {
  schedule: events.Schedule.rate(Duration.minutes(1)),
  targets: [new targets.ApiDestination(destination)],
});
```

## Initializer

```ts
new Authorization()
```

## Methods

- `apiKey(apiKeyName: string, apiKeyValue: SecretValue): Authorization // chainable` (static) — Use API key authorization.

  API key authorization has two components: an API key name and an API key value.
  What these are depends on the target of your connection.

- `basic(username: string, password: SecretValue): Authorization // chainable` (static) — Use username and password authorization.

- `oauth(props: OAuthAuthorizationProps): Authorization // chainable` (static) — Use OAuth authorization.
