# GithubOAuth2CredentialProviderProps

Props for {@link OAuth2CredentialProvider.usingGithub}.

Extends: [OAuth2CredentialProviderFactoryBaseProps](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_bedrockagentcore.OAuth2CredentialProviderFactoryBaseProps.html)
Used as argument in: [OAuth2CredentialProvider.usingGithub](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_bedrockagentcore.OAuth2CredentialProvider.html#usinggithub)

- Source: [`aws-bedrockagentcore/lib/identity/oauth2-credential-provider.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-bedrockagentcore/lib/identity/oauth2-credential-provider.ts#L274)
- Type last changed: v2.255.0 · 19 May 2026

## Example

TypeScript:

```ts
const gateway = new agentcore.Gateway(this, "MyGateway", {
  gatewayName: "my-gateway",
});

const oauth = agentcore.OAuth2CredentialProvider.usingGithub(this, "GhOAuth", {
  oAuth2CredentialProviderName: "github-oauth",
  clientId: "your-client-id",
  clientSecret: cdk.SecretValue.unsafePlainText("your-client-secret"),
});

gateway.addMcpServerTarget("Mcp", {
  gatewayTargetName: "mcp-server",
  description: "MCP with GitHub OAuth",
  endpoint: "https://my-mcp-server.example.com",
  credentialProviderConfigurations: [
    agentcore.GatewayCredentialProvider.fromOauthIdentity(oauth, {
      scopes: ["read:user"],
    }),
  ],
});
```

Python:

```python
gateway = agentcore.Gateway(self, "MyGateway",
    gateway_name="my-gateway"
)

oauth = agentcore.OAuth2CredentialProvider.using_github(self, "GhOAuth",
    o_auth2_credential_provider_name="github-oauth",
    client_id="your-client-id",
    client_secret=cdk.SecretValue.unsafe_plain_text("your-client-secret")
)

gateway.add_mcp_server_target("Mcp",
    gateway_target_name="mcp-server",
    description="MCP with GitHub OAuth",
    endpoint="https://my-mcp-server.example.com",
    credential_provider_configurations=[
        agentcore.GatewayCredentialProvider.from_oauth_identity(oauth,
            scopes=["read:user"]
        )
    ]
)
```

Java:

```java
Gateway gateway = Gateway.Builder.create(this, "MyGateway")
        .gatewayName("my-gateway")
        .build();

OAuth2CredentialProvider oauth = OAuth2CredentialProvider.usingGithub(this, "GhOAuth", GithubOAuth2CredentialProviderProps.builder()
        .oAuth2CredentialProviderName("github-oauth")
        .clientId("your-client-id")
        .clientSecret(SecretValue.unsafePlainText("your-client-secret"))
        .build());

gateway.addMcpServerTarget("Mcp", AddMcpServerTargetOptions.builder()
        .gatewayTargetName("mcp-server")
        .description("MCP with GitHub OAuth")
        .endpoint("https://my-mcp-server.example.com")
        .credentialProviderConfigurations(List.of(GatewayCredentialProvider.fromOauthIdentity(oauth, FromOauthIdentityOptions.builder()
                .scopes(List.of("read:user"))
                .build())))
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
var gateway = new Gateway(this, "MyGateway", new GatewayProps {
    GatewayName = "my-gateway"
});

var oauth = OAuth2CredentialProvider.UsingGithub(this, "GhOAuth", new GithubOAuth2CredentialProviderProps {
    OAuth2CredentialProviderName = "github-oauth",
    ClientId = "your-client-id",
    ClientSecret = SecretValue.UnsafePlainText("your-client-secret")
});

gateway.AddMcpServerTarget("Mcp", new AddMcpServerTargetOptions {
    GatewayTargetName = "mcp-server",
    Description = "MCP with GitHub OAuth",
    Endpoint = "https://my-mcp-server.example.com",
    CredentialProviderConfigurations = new [] { GatewayCredentialProvider.FromOauthIdentity(oauth, new FromOauthIdentityOptions {
        Scopes = new [] { "read:user" }
    }) }
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
gateway := agentcore.NewGateway(this, jsii.String("MyGateway"), &GatewayProps{
	GatewayName: jsii.String("my-gateway"),
})

oauth := agentcore.OAuth2CredentialProvider_UsingGithub(this, jsii.String("GhOAuth"), &GithubOAuth2CredentialProviderProps{
	OAuth2CredentialProviderName: jsii.String("github-oauth"),
	ClientId: jsii.String("your-client-id"),
	ClientSecret: cdk.SecretValue_UnsafePlainText(jsii.String("your-client-secret")),
})

gateway.AddMcpServerTarget(jsii.String("Mcp"), &AddMcpServerTargetOptions{
	GatewayTargetName: jsii.String("mcp-server"),
	Description: jsii.String("MCP with GitHub OAuth"),
	Endpoint: jsii.String("https://my-mcp-server.example.com"),
	CredentialProviderConfigurations: []ICredentialProviderConfig{
		agentcore.GatewayCredentialProvider_FromOauthIdentity(oauth, &FromOauthIdentityOptions{
			Scopes: []*string{
				jsii.String("read:user"),
			},
		}),
	},
})
```

## Properties

- `clientId`: string (required) — OAuth2 client identifier.

- `clientSecret`: [SecretValue](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.SecretValue.html) (required) — OAuth2 client secret.

  **NOTE:** The client secret will be included in the CloudFormation template as part of synthesis.
  The service stores the secret in Secrets Manager after creation, but the value is visible
  in the template and deployment history. Use `SecretValue.unsafePlainText()` to explicitly
  acknowledge plaintext, or pass a reference from another construct to avoid embedding the
  literal value.

- `oAuth2CredentialProviderName`: string — Name of the credential provider.

  **Default:** a name generated by CDK

- `tags`: { [key: string]: string } — Tags for this credential provider.

  **Default:** no tags
