Skip to content
v2.277.0

OAuthFlows Struct ​

Types of OAuth grant flows.

Example ​

ts
const userpool = new cognito.UserPool(this, 'UserPool', {
  // ...
});
const client = userpool.addClient('Client', {
  // ...
  oAuth: {
    flows: {
      implicitCodeGrant: true,
    },
    callbackUrls: [
      'https://myapp.com/home',
      'https://myapp.com/users',
    ],
  },
});
const domain = userpool.addDomain('Domain', {
  // ...
});
const signInUrl = domain.signInUrl(client, {
  redirectUri: 'https://myapp.com/home', // must be a URL configured under 'callbackUrls' with the client
});
python
userpool = cognito.UserPool(self, "UserPool")
client = userpool.add_client("Client",
    # ...
    o_auth=cognito.OAuthSettings(
        flows=cognito.OAuthFlows(
            implicit_code_grant=True
        ),
        callback_urls=["https://myapp.com/home", "https://myapp.com/users"
        ]
    )
)
domain = userpool.add_domain("Domain")
sign_in_url = domain.sign_in_url(client,
    redirect_uri="https://myapp.com/home"
)
java
UserPool userpool = UserPool.Builder.create(this, "UserPool").build();
UserPoolClient client = userpool.addClient("Client", UserPoolClientOptions.builder()
        // ...
        .oAuth(OAuthSettings.builder()
                .flows(OAuthFlows.builder()
                        .implicitCodeGrant(true)
                        .build())
                .callbackUrls(List.of("https://myapp.com/home", "https://myapp.com/users"))
                .build())
        .build());
UserPoolDomain domain = userpool.addDomain("Domain", UserPoolDomainOptions.builder().build());
String signInUrl = domain.signInUrl(client, SignInUrlOptions.builder()
        .redirectUri("https://myapp.com/home")
        .build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
var userpool = new UserPool(this, "UserPool", new UserPoolProps { });
var client = userpool.AddClient("Client", new UserPoolClientOptions {
    // ...
    OAuth = new OAuthSettings {
        Flows = new OAuthFlows {
            ImplicitCodeGrant = true
        },
        CallbackUrls = new [] { "https://myapp.com/home", "https://myapp.com/users" }
    }
});
var domain = userpool.AddDomain("Domain", new UserPoolDomainOptions { });
var signInUrl = domain.SignInUrl(client, new SignInUrlOptions {
    RedirectUri = "https://myapp.com/home"
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
userpool := cognito.NewUserPool(this, jsii.String("UserPool"), &UserPoolProps{
})
client := userpool.addClient(jsii.String("Client"), &UserPoolClientOptions{
	// ...
	OAuth: &OAuthSettings{
		Flows: &OAuthFlows{
			ImplicitCodeGrant: jsii.Boolean(true),
		},
		CallbackUrls: []*string{
			jsii.String("https://myapp.com/home"),
			jsii.String("https://myapp.com/users"),
		},
	},
})
domain := userpool.addDomain(jsii.String("Domain"), &UserPoolDomainOptions{
})
signInUrl := domain.SignInUrl(client, &SignInUrlOptions{
	RedirectUri: jsii.String("https://myapp.com/home"),
})

Properties ​

authorizationCodeGrantoptionalbooleanauthorization_code_grantoptionalboolauthorizationCodeGrantoptionalBooleanAuthorizationCodeGrantoptionalboolAuthorizationCodeGrantoptional*bool= false#
Initiate an authorization code grant flow, which provides an authorization code as the response.
clientCredentialsoptionalbooleanclient_credentialsoptionalboolclientCredentialsoptionalBooleanClientCredentialsoptionalboolClientCredentialsoptional*bool= false#
Client should get the access token and ID token from the token endpoint using a combination of client and client_secret.
implicitCodeGrantoptionalbooleanimplicit_code_grantoptionalboolimplicitCodeGrantoptionalBooleanImplicitCodeGrantoptionalboolImplicitCodeGrantoptional*bool= false#
The client should get the access token and ID token directly.