[GH-ISSUE #5441] Pass IDP name to Cognito to allow user to skip Cognito IDP selection screen #27567

Open
opened 2026-04-17 18:38:58 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @krmrn42 on GitHub (Oct 20, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/5441

Originally assigned to: @ping-maxwell on GitHub.

Is this suited for github?

  • Yes, this is suited for github

I authenticate users with Google via Amazon Cognito. Cognito allows sending the users directly to the identity provider login page bypassing the identity provider selection via passing identity_provider or idp_identifier parameter in the authorize endpoint. From what I see, Better Auth Cognito provider does not allow passing this parameter when creating the auth URL.

Describe the solution you'd like

Expose additionalParams in signInSocial endpoint params [1], pass it to createAuthorizationURL [2], and pass-through as-is in cognito impl [3].

**Advantage of this approach: ** I can implement my own sign-in buttons and call signIn.social passing the relevant provider to cognito. Immediately potentially useful for other providers.

This approach allows functionality similar to NextAuth in signIn action

Describe alternatives you've considered

Alternatively, similar to #3419 and #1990: add identityProvider to CognitoOptions and pass it to createAuthorizationURL via additionalParams.

**Advantage of this approach: ** More straight-forward to implement.

Additional context

No response

Originally created by @krmrn42 on GitHub (Oct 20, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/5441 Originally assigned to: @ping-maxwell on GitHub. ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. I authenticate users with Google via Amazon Cognito. Cognito allows sending the users directly to the identity provider login page bypassing the identity provider selection via passing `identity_provider` or `idp_identifier` parameter in the authorize endpoint. From what I see, Better Auth Cognito provider does not allow passing this parameter when creating the auth URL. ### Describe the solution you'd like Expose `additionalParams` in `signInSocial` endpoint params [[1](https://github.com/better-auth/better-auth/blob/2cf7d0229d03ab10c8d7bddfb18f37e9b07dc18d/packages/better-auth/src/api/routes/sign-in.ts#L15)], pass it to `createAuthorizationURL` [[2](https://github.com/better-auth/better-auth/blob/2cf7d0229d03ab10c8d7bddfb18f37e9b07dc18d/packages/better-auth/src/api/routes/sign-in.ts#L322)], and pass-through as-is in cognito impl [[3](https://github.com/better-auth/better-auth/blob/b515c16c49852f718c9df39a4d57fe519e5a7e0f/packages/core/src/social-providers/cognito.ts#L60C9-L60C31)]. **Advantage of this approach: ** I can implement my own sign-in buttons and call `signIn.social` passing the relevant provider to cognito. Immediately potentially useful for other providers. This approach allows functionality similar to NextAuth in [signIn action](https://github.com/nextauthjs/next-auth/blob/0bcd32d6eb0a10f249820557d9c649e502daaf8b/packages/next-auth/src/lib/actions.ts#L41-L43) ### Describe alternatives you've considered Alternatively, similar to #3419 and #1990: add `identityProvider` to `CognitoOptions` and pass it to `createAuthorizationURL` via `additionalParams`. **Advantage of this approach: ** More straight-forward to implement. ### Additional context _No response_
GiteaMirror added the oauth label 2026-04-17 18:38:58 -05:00
Author
Owner

@EdiAfremovFactify commented on GitHub (Nov 5, 2025):

I’m trying to migrate from NextAuth.

This is currently a blocker for me.

Besides waiting for the PR, is there any other workaround to pass the IDP to the Cognito provider?

<!-- gh-comment-id:3489705090 --> @EdiAfremovFactify commented on GitHub (Nov 5, 2025): I’m trying to migrate from NextAuth. This is currently a blocker for me. Besides waiting for the PR, is there any other workaround to pass the IDP to the Cognito provider?
Author
Owner

@krmrn42 commented on GitHub (Nov 5, 2025):

Same here. I've installed from #5443 for now (although it's weeks behind):

npm i https://pkg.pr.new/better-auth/better-auth@5443

If this is not merged for any reason, I guess I'll go with a custom cognito provider implementation so I can keep deps up to date.

@Bekacru @himself65 anything we can do to merge the PR?

<!-- gh-comment-id:3492461563 --> @krmrn42 commented on GitHub (Nov 5, 2025): Same here. I've installed from #5443 for now (although it's weeks behind): ```bash npm i https://pkg.pr.new/better-auth/better-auth@5443 ``` If this is not merged for any reason, I guess I'll go with a custom cognito provider implementation so I can keep deps up to date. @Bekacru @himself65 anything we can do to merge the PR?
Author
Owner

@lewisvrobinson commented on GitHub (Feb 4, 2026):

We're working around this at the moment by using the genericOAuth plugin but it would be great to have this properly handled by the Cognito plugin since this is a pretty common use case.

<!-- gh-comment-id:3845188538 --> @lewisvrobinson commented on GitHub (Feb 4, 2026): We're working around this at the moment by using the genericOAuth plugin but it would be great to have this properly handled by the Cognito plugin since this is a pretty common use case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#27567