> **Experimental**
>
> `@aws-cdk/aws-amplify-alpha` is an [**experimental**](https://docs.aws.amazon.com/cdk/api/stability.html) (alpha) package: its API may change in any release, without a major version bump.
# BasicAuth

Basic Auth configuration.

Obtainable from: BasicAuth.fromCredentials, BasicAuth.fromGeneratedPassword

- Stability: [Experimental](https://docs.aws.amazon.com/cdk/api/stability.html)
- Source: [`lib/basic-auth.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/@aws-cdk/aws-amplify-alpha/lib/basic-auth.ts#L54)

## Example

TypeScript:

```ts
const amplifyApp = new amplify.App(this, 'MyApp', {
  sourceCodeProvider: new amplify.GitHubSourceCodeProvider({
    owner: '<user>',
    repository: '<repo>',
    oauthToken: SecretValue.secretsManager('my-github-token'),
  }),
  basicAuth: amplify.BasicAuth.fromGeneratedPassword('username'),
});
```

Python:

```python
amplify_app = amplify.App(self, "MyApp",
    source_code_provider=amplify.GitHubSourceCodeProvider(
        owner="<user>",
        repository="<repo>",
        oauth_token=SecretValue.secrets_manager("my-github-token")
    ),
    basic_auth=amplify.BasicAuth.from_generated_password("username")
)
```

Java:

```java
App amplifyApp = App.Builder.create(this, "MyApp")
        .sourceCodeProvider(GitHubSourceCodeProvider.Builder.create()
                .owner("<user>")
                .repository("<repo>")
                .oauthToken(SecretValue.secretsManager("my-github-token"))
                .build())
        .basicAuth(BasicAuth.fromGeneratedPassword("username"))
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.AWS.Amplify.Alpha
var amplifyApp = new App(this, "MyApp", new AppProps {
    SourceCodeProvider = new GitHubSourceCodeProvider(new GitHubSourceCodeProviderProps {
        Owner = "<user>",
        Repository = "<repo>",
        OauthToken = SecretValue.SecretsManager("my-github-token")
    }),
    BasicAuth = BasicAuth.FromGeneratedPassword("username")
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdkamplifyalpha/v2
amplifyApp := amplify.NewApp(this, jsii.String("MyApp"), &AppProps{
	SourceCodeProvider: amplify.NewGitHubSourceCodeProvider(&GitHubSourceCodeProviderProps{
		Owner: jsii.String("<user>"),
		Repository: jsii.String("<repo>"),
		OauthToken: awscdk.SecretValue_SecretsManager(jsii.String("my-github-token")),
	}),
	BasicAuth: amplify.BasicAuth_FromGeneratedPassword(jsii.String("username")),
})
```

## Initializer

TypeScript:

```ts
new BasicAuth(props: BasicAuthProps)
```

Python:

```python
BasicAuth(props: BasicAuthProps)
```

Java:

```java
new BasicAuth(BasicAuthProps props)
```

C# / .NET:

```csharp
new BasicAuth(BasicAuthProps props)
```

Golang:

```go
NewBasicAuth(Props BasicAuthProps)
```

## Methods

- `bind(scope: Construct, id: string): BasicAuthConfig` — Binds this Basic Auth configuration to an App.

- `fromCredentials(username: string, password: SecretValue): BasicAuth // chainable` (static) — Creates a Basic Auth configuration from a username and a password.

  **Parameters**

  - `username` — The username.
  - `password` — The password.

- `fromGeneratedPassword(username: string, encryptionKey?: IKey): BasicAuth // chainable` (static) — Creates a Basic Auth configuration with a password generated in Secrets Manager.

  **Parameters**

  - `username` — The username.
  - `encryptionKey` — The encryption key to use to encrypt the password in Secrets Manager.
