# IdentitySource

Represents an identity source.

The source can be specified either as a literal value (e.g: `Auth`) which
cannot be blank, or as an unresolved string token.

- Source: [`aws-apigateway/lib/authorizers/identity-source.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-apigateway/lib/authorizers/identity-source.ts#L10)

## Example

TypeScript:

```ts
declare const authFn: lambda.Function;
declare const books: apigateway.Resource;

const auth = new apigateway.RequestAuthorizer(this, 'booksAuthorizer', {
  handler: authFn,
  identitySources: [apigateway.IdentitySource.header('Authorization')]
});

books.addMethod('GET', new apigateway.HttpIntegration('http://amazon.com'), {
  authorizer: auth
});
```

Python:

```python
# auth_fn: lambda.Function
# books: apigateway.Resource

auth = apigateway.RequestAuthorizer(self, "booksAuthorizer",
    handler=auth_fn,
    identity_sources=[apigateway.IdentitySource.header("Authorization")]
)

books.add_method("GET", apigateway.HttpIntegration("http://amazon.com"),
    authorizer=auth
)
```

Java:

```java
Function authFn;
Resource books;

RequestAuthorizer auth = RequestAuthorizer.Builder.create(this, "booksAuthorizer")
        .handler(authFn)
        .identitySources(List.of(IdentitySource.header("Authorization")))
        .build();

books.addMethod("GET", new HttpIntegration("http://amazon.com"), MethodOptions.builder()
        .authorizer(auth)
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
Function authFn;
Resource books;

var auth = new RequestAuthorizer(this, "booksAuthorizer", new RequestAuthorizerProps {
    Handler = authFn,
    IdentitySources = new [] { IdentitySource.Header("Authorization") }
});

books.AddMethod("GET", new HttpIntegration("http://amazon.com"), new MethodOptions {
    Authorizer = auth
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var authFn Function
var books Resource

auth := apigateway.NewRequestAuthorizer(this, jsii.String("booksAuthorizer"), &RequestAuthorizerProps{
	Handler: authFn,
	IdentitySources: []*string{
		apigateway.IdentitySource_Header(jsii.String("Authorization")),
	},
})

books.AddMethod(jsii.String("GET"), apigateway.NewHttpIntegration(jsii.String("http://amazon.com")), &MethodOptions{
	Authorizer: auth,
})
```

## Initializer

TypeScript:

```ts
new IdentitySource()
```

Python:

```python
IdentitySource()
```

Java:

```java
new IdentitySource()
```

C# / .NET:

```csharp
new IdentitySource()
```

Golang:

```go
NewIdentitySource()
```

## Methods

- `context(context: string): string` (static) — Provides a properly formatted request context identity source.

  **Parameters**

  - `context` — the name of the context variable the `IdentitySource` will represent.

  **Returns:** a request context identity source.

- `header(headerName: string): string` (static) — Provides a properly formatted header identity source.

  **Parameters**

  - `headerName` — the name of the header the `IdentitySource` will represent.

  **Returns:** a header identity source.

- `queryString(queryString: string): string` (static) — Provides a properly formatted query string identity source.

  **Parameters**

  - `queryString` — the name of the query string the `IdentitySource` will represent.

  **Returns:** a query string identity source.

- `stageVariable(stageVariable: string): string` (static) — Provides a properly formatted API Gateway stage variable identity source.

  **Parameters**

  - `stageVariable` — the name of the stage variable the `IdentitySource` will represent.

  **Returns:** an API Gateway stage variable identity source.
