signInDetails undefined on OAuth siginIn (signInWithRedirect)
Before opening, please confirm:
- [X] I have searched for duplicate or closed issues and discussions.
- [X] I have read the guide for submitting bug reports.
- [X] 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
Amplify CLI
Environment information
# Put output below this line
System:
OS: macOS 14.2.1
CPU: (8) arm64 Apple M2
Memory: 60.88 MB / 16.00 GB
Shell: 3.2.57 - /bin/sh
Binaries:
Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
Yarn: 1.23.0-20220130.1630 - ~/.nvm/versions/node/v20.10.0/bin/yarn
npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm
pnpm: 9.3.0 - ~/.nvm/versions/node/v20.10.0/bin/pnpm
Browsers:
Chrome: 126.0.6478.116
Safari: 17.2.1
Safari Technology Preview: 17.4
npmPackages:
@aws-amplify/auth: 6.3.7 => 6.3.7
@aws-amplify/core: 6.3.3 => 6.3.3
@aws-amplify/ui-react: 6.1.12 => 6.1.12
@aws-amplify/ui-react-core: 3.0.16 => 3.0.16
@hookform/devtools: ^4.3.1 => 4.3.1
@mui/icons-material: ^5.15.19 => 5.15.20
@mui/material: ^5.15.19 => 5.15.20
@mui/x-date-pickers: ^7.6.2 => 7.7.0
@odoreltd/commons: workspace:* => 0.1.13
@odoreltd/domain: workspace:* => 0.0.1
@odoreltd/mocks: workspace:* => 0.0.1
@odoreltd/osiris-api: workspace:* => 0.0.1
@odoreltd/osiris-components: workspace:* => 0.0.1
@odoreltd/osiris-domain: workspace:* => 0.0.1
@odoreltd/test-utils: workspace:* => 0.0.1
@odoreltd/utils: workspace:* => 0.0.1
@odoreltd/vite-plugin-iife: workspace:* => 0.0.1
@odoreltd/vite-plugin-svgr-props: workspace:* => 0.0.1
@sentry/browser: ^7.113.0 => 7.117.0
@sentry/react: ^7.113.0 => 7.117.0
@testing-library/react: ^12.1.5 => 12.1.5
@testing-library/react-hooks: ^8.0.1 => 8.0.1
@testing-library/user-event: ^12.1.5 => 12.8.3
@types/react: ^17.0.2 => 17.0.80
@types/react-dom: ^17.0.2 => 17.0.25
@types/react-router: ^5.1.20 => 5.1.20
@types/react-router-dom: ^5.3.3 => 5.3.3
@vitejs/plugin-react-swc: ^3.2.0 => 3.7.0
aws-amplify: 6.3.8 => 6.3.8
history: ^4.7.2 => 4.10.1
moment: ^2.29.4 => 2.30.1
moment-duration-format: ^2.3.2 => 2.3.2
msw: ^1.3.2 => 1.3.3
react: ^17.0.2 => 17.0.2
react-dom: ^17.0.2 => 17.0.2
react-hook-form: ^7.50.1 => 7.51.5
react-router: ^5.2.0 => 5.3.4
react-router-dom: ^5.2.1 => 5.3.4
tss-react: ^4.4.4 => 4.9.10
typescript: ^5.0.4 => 5.2.2
vite: ^5.3.1 => 5.3.1
vitest: ^1.1.0 => 1.1.0
npmGlobalPackages:
acorn: 8.11.3
corepack: 0.22.0
jwt-cracker: 4.1.1
npm: 10.2.3
nx: 17.2.8
pnpm: 9.3.0
ts-node: 10.9.2
typescript-call-graph: 0.0.3
yarn: 1.22.21
Describe the bug
getCurrentUser does not return signInDetails if the user is signed in using OAuth (an IdentityProvider like google). The data for it is available in the idToken, and can be accessed directly through token payload, but is not returned by getCurrentUser.
Expected behavior
getCurrentUser returns consistent information regardless of how the user is signed in, especially if the data is actually available (meaning it's not a limitation related to the particular identity provider).
Reproduction steps
There are no specific conditions for reproducing this other than using signInWithRedirect (we're using specifically google identity provider), but here it goes:
import { fetchAuthSession, signInWithRedirect, getCurrentUser } from 'aws-amplify/auth';
fetchAuthSession().then(({ tokens }) => {
if (tokens) {
return signInWithRedirect({ provider: 'Google' });
}
return getCurrentUser().then(console.log); // => { userId: string; username: string }
});
Code Snippet
// Put your code below this line.
Log output
// Put your logs below this line
aws-exports.js
/* eslint-disable */
// WARNING: DO NOT EDIT. This file is automatically generated by AWS Amplify. It will be overwritten.
const awsmobile = {
aws_project_region: 'eu-west-2',
aws_cognito_region: 'eu-west-2',
aws_user_pools_id: import.meta.env.VITE_AWS_USER_POOLS_ID,
aws_user_pools_web_client_id: import.meta.env.VITE_AWS_USER_POOLS_WEB_CLIENT_ID,
oauth: {
domain: import.meta.env.VITE_AWS_OAUTH_DOMAIN,
scope: ['email', 'openid', 'profile'],
redirectSignIn: import.meta.env.VITE_REDIRECT_URL,
redirectSignOut: import.meta.env.VITE_REDIRECT_URL,
responseType: 'code',
},
federationTarget: 'COGNITO_USER_POOLS',
aws_cognito_username_attributes: ['EMAIL'],
aws_cognito_social_providers: ['GOOGLE'],
aws_cognito_signup_attributes: ['EMAIL'],
aws_cognito_mfa_configuration: 'OFF',
aws_cognito_mfa_types: ['SMS'],
aws_cognito_password_protection_settings: {
passwordPolicyMinLength: 8,
passwordPolicyCharacters: [],
},
aws_cognito_verification_mechanisms: ['EMAIL'],
};
export default awsmobile;
Manual configuration
No response
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
Hello, @raegen and thanks for opening this issue. While the signInDetails are not supported when using Hosted UI or the signInWithRedirect API (as noted here in docs), but we'll consider this issue a feature request to add that functionality into the signInWithRedirect API calls.
Can you give us more details about the use case and context as to why you're looking to do this within your OAuth flow? For example, what kind of information are you looking to capture from the OAuth flow (i.e. provider, Auth flow type, or something else)?
@raegen, just wanted to ping you to see if we can get more details on this to understand the use case and context. Thanks!
Closing this issue as we have not heard back from you. This is not supported and documented here, but if there's additional use cases or context we are missing from the community then feel free to add comments and we can reopen.
Thank you!