-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
AuthRelated to Auth components/categoryRelated to Auth components/categoryquestionGeneral questionGeneral question
Description
Before opening, please confirm:
- I have searched for duplicate or closed issues and discussions.
- I have read the guide for submitting bug reports.
- I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
JavaScript Framework
React
Amplify APIs
Authentication
Amplify Version
v6
Amplify Categories
auth
Backend
Other
Environment information
# Put output below this line
System:
OS: macOS 15.4.1
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.11.1 - /usr/local/bin/node
Yarn: 1.22.19 - ~/.yarn/bin/yarn
npm: 10.2.4 - /usr/local/bin/npm
pnpm: 10.10.0 - /usr/local/bin/pnpm
Watchman: 2025.04.14.00 - /opt/homebrew/bin/watchman
npmPackages:
@aws-amplify/auth: ^6.12.4 => 6.12.4
@aws-amplify/auth/cognito: undefined ()
@aws-amplify/auth/cognito/server: undefined ()
@aws-amplify/auth/enable-oauth-listener: undefined ()
@aws-amplify/auth/server: undefined ()
@aws-amplify/core: ^6.11.4 => 6.11.4
@aws-amplify/core/internals/adapter-core: undefined ()
@aws-amplify/core/internals/aws-client-utils: undefined ()
@aws-amplify/core/internals/aws-client-utils/composers: undefined ()
@aws-amplify/core/internals/aws-clients/cognitoIdentity: undefined ()
@aws-amplify/core/internals/aws-clients/pinpoint: undefined ()
@aws-amplify/core/internals/providers/pinpoint: undefined ()
@aws-amplify/core/internals/utils: undefined ()
@aws-amplify/core/server: undefined ()
@aws-amplify/ui-react: ^6.11.1 => 6.11.1
@aws-amplify/ui-react-internal: undefined ()
@aws-amplify/ui-react-server: undefined ()
@eslint/js: ^9.21.0 => 9.26.0
@tailwindcss/vite: ^4.1.6 => 4.1.6
@types/react: ^19.0.10 => 19.1.3
@types/react-dom: ^19.0.4 => 19.1.3
@vitejs/plugin-react: ^4.3.4 => 4.4.1
@vitejs/plugin-react-swc: ^3.8.0 => 3.9.0
autoprefixer: ^10.4.21 => 10.4.21
aws-amplify: ^6.14.4 => 6.14.4
aws-amplify/adapter-core: undefined ()
aws-amplify/adapter-core/internals: undefined ()
aws-amplify/analytics: undefined ()
aws-amplify/analytics/kinesis: undefined ()
aws-amplify/analytics/kinesis-firehose: undefined ()
aws-amplify/analytics/personalize: undefined ()
aws-amplify/analytics/pinpoint: undefined ()
aws-amplify/api: undefined ()
aws-amplify/api/internals: undefined ()
aws-amplify/api/server: undefined ()
aws-amplify/auth: undefined ()
aws-amplify/auth/cognito: undefined ()
aws-amplify/auth/cognito/server: undefined ()
aws-amplify/auth/enable-oauth-listener: undefined ()
aws-amplify/auth/server: undefined ()
aws-amplify/data: undefined ()
aws-amplify/data/server: undefined ()
aws-amplify/datastore: undefined ()
aws-amplify/in-app-messaging: undefined ()
aws-amplify/in-app-messaging/pinpoint: undefined ()
aws-amplify/push-notifications: undefined ()
aws-amplify/push-notifications/pinpoint: undefined ()
aws-amplify/storage: undefined ()
aws-amplify/storage/s3: undefined ()
aws-amplify/storage/s3/server: undefined ()
aws-amplify/storage/server: undefined ()
aws-amplify/utils: undefined ()
eslint: ^9.21.0 => 9.26.0
eslint-plugin-react-hooks: ^5.1.0 => 5.2.0
eslint-plugin-react-refresh: ^0.4.19 => 0.4.20
formik: ^2.4.6 => 2.4.6
globals: ^15.15.0 => 15.15.0 (11.12.0, 14.0.0)
react: ^19.0.0 => 19.1.0
react-dom: ^19.0.0 => 19.1.0
react-router-dom: ^7.6.0 => 7.6.0
tailwindcss: ^4.1.6 => 4.1.6
typescript: ~5.7.2 => 5.7.3
typescript-eslint: ^8.24.1 => 8.32.0
vite: ^6.2.0 => 6.3.5
vite-plugin-wasm-pack: ^0.1.12 => 0.1.12
zod: ^3.24.4 => 3.24.4
zod-formik-adapter: ^1.3.0 => 1.3.0
Describe the bug
Background
- I am using the Cognito Hosted UI and attempting to integrate Amplify React with it
Authentication Failure
signInWithRedirect()
works as expected. Hosted UI works as expected.- When the callback is called (URL like
http://localhost:5173/auth/callback/cognito?code=54cb747...&state=NzaXyK7...
), the network inspector does show a successful request to <cognito_domain>/oauth2/tokens that must be made by Amplify because it is not made by my app itself. - However, the JWT contained within the response is not stored by Amplify and
fetchUserSession
continues to return an empty response (even when polled).
I suspect that this is a documentation gap rather than a bug, but without that documentation I cannot know for sure.
Docs issues/omissions
- There is no explicit documentation on integrating Amplify with Cognito's Hosted UI. I already have a number of SAML providers connected to the user pool, that user pool is working and I don't want to duplicate that information within Amplify, especially when Amplify is not working from the start. That approach is the only one documented by Amplify.
- Searching for
Hosted UI
in the Amplify docs only turns up admonitions about particular behaviors not supported with the Hosted UI.fetchUserSession
has no such note and I would expect session management to still work.
- Searching for
- I cannot find any public documentation on the expected behavior of
aws-amplify/auth/enable-oauth-listener
. I only even know that it exists from github issues and gen AI suggestions. Google it to see what I mean.
Expected behavior
- Auth callback from Cognito Hosted UI (with code & state) should be handled and result in an active user session
- Hosted UI + Amplify integration should be directly and explicitly documented
Reproduction steps
- Configure a Cognito User Pool with a hosted UI and 3rd-party SAML providers
- Configure a React App with Amplify to use this pool
- Call
signInWithRedirect
and successfully sign in - See that the callback is not properly handled by Amplify
Code Snippet
App root:
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App.tsx'
import "aws-amplify/auth/enable-oauth-listener";
createRoot(document.getElementById('root')!).render(
<StrictMode>
<App />
</StrictMode>,
)
Log output
// Put your logs below this line
aws-exports.js
No response
Manual configuration
const amplifyConfig = {
Auth: {
Cognito: {
userPoolId: 'us-west-2_..,
userPoolClientId: '...',
loginWith: {
oauth: {
domain: 'redacted.auth.us-west-2.amazoncognito.com',
scopes: ['email', 'profile', 'openid'],
redirectSignIn: ['http://localhost:5173/auth/callback/cognito'],
redirectSignOut: ['http://localhost:5173/'],
responseType: 'code' as const
}
}
}
}
};
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
Metadata
Metadata
Assignees
Labels
AuthRelated to Auth components/categoryRelated to Auth components/categoryquestionGeneral questionGeneral question