Skip to content
v2.278.0

GithubOAuth2CredentialProviderProps Struct ​

Props for {@link OAuth2CredentialProvider.usingGithub}.

Example ​

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
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
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());
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" }
    }) }
});
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 ​

clientIdstringclient_idstrclientIdStringClientIdstringClientId*string required #
OAuth2 client identifier.
clientSecretSecretValueclient_secretSecretValueclientSecretSecretValueClientSecretSecretValueClientSecretSecretValue required #
OAuth2 client secret.
notes

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.

oAuth2CredentialProviderNameoptionalstringo_auth2_credential_provider_nameoptionalstroAuth2CredentialProviderNameoptionalStringOAuth2CredentialProviderNameoptionalstringOAuth2CredentialProviderNameoptional*string #
Name of the credential provider.

Default: a name generated by CDK

tagsoptional{ [key: string]: string }tagsoptionaltyping.Mapping[str, str]tagsoptionalMap<String, String>TagsoptionalIDictionary<string, string>Tagsoptional*map[string]*string #
Tags for this credential provider.

Default: no tags