Skip to content

Conversation

@dimitor115
Copy link

Hi all, while implementing an AWS User Pool in AWS Cognito I ran into a small inconvenience with the addClient method. AFAIK, the callbackUrl is required for the managed login flow to redirect back to your app, but it isn’t exposed as an input parameter, so you currently have to rely on a small transform workaround:

My current code:

    const webClient = userPool.addClient("Web", {
      transform: {
        client: (args: UserPoolClientArgs) => {
          args.callbackUrls = [adminUI.url.apply(url => `${url}/auth/callback`)];
        },
      },
    });

While I believe it's quite convenient requirement, so it could look like this:

    const webClient = userPool.addClient("Web", {
      callbackUrls: [adminUI.url.apply(url => `${url}/auth/callback`)]
    });

Please let me know if that makes sense for you to expose it.

@vimtor vimtor self-requested a review December 10, 2025 12:46
Copy link
Collaborator

@vimtor vimtor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the contribution @dimitor115

problem now is that if the user skips callbackUrls you get:

| Error Web sst:aws:CognitoUserPoolClient → WebClient aws:cognito:UserPoolClient
creating Cognito User Pool Client (Web): operation error Cognito Identity Provider: CreateUserPoolClient, https response error StatusCode: 400, RequestID: d56889f8-e70d-4983-a441-97ce613d900e, InvalidOAuthFlowException: CallbackUrls can not be empty when code flow or implicit flow is selected

i proposed a change to keep it compatible with existing defaults, but yeah that https://example.com looks suspicious

maybe callbackUrls should just be required?

@vimtor vimtor self-assigned this Dec 10, 2025
@dimitor115
Copy link
Author

Personally I believe it should be required, but as far as I see it's not required in Pulumi as well. This makes me think, let's keep it backward compatible and fallback to example.com

@dimitor115 dimitor115 changed the title Add callbackUrls to aws cogito userpool client args Add callbackUrls to aws cognito userpool client args Dec 10, 2025
Co-authored-by: Victor Navarro <vn4varro@gmail.com>
dimitor115 and others added 2 commits December 11, 2025 17:16
Co-authored-by: Victor Navarro <vn4varro@gmail.com>
Co-authored-by: Victor Navarro <vn4varro@gmail.com>
Copy link
Collaborator

@vimtor vimtor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good work!

const userPool = new sst.aws.CognitoUserPool("MyUserPool", {
  triggers: {
    preSignUp: {
      handler: "index.handler",
    },
  },
});

const client = userPool.addClient("Web", {
  callbackUrls: ["https://sst.dev/auth/callback"],
});
Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants