-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auth.federatedSignIn with Google calling /token endpoint twice #6330
Comments
I am experiencing the same issue with Google federated sign in. |
Some thoughts. It seems you have two redirect signins/signouts, I want to confirm that you're calling Lastly, can you (A) go to the AWS Cognito User Pool (in the AWS Console), remove the user that you're trying to log in, and do the same for the GCP OAuth app (in the GCP console)? Then try yet another log in. If none of the above works, please let us know. |
Hey @harrysolovay thanks for the suggestion. Unfortunately it did not work. Cheers |
@harrysolovay I noticed the same console error but it is actually not causing any tangible problems for me other than a duplicate request and console error. I am running a React project and calling Amplify.configure in App.ts (first child of root). Let me know if any other details I can provide to help. Edit: I realized that this might not be clear. When I call |
@seanbecker15 are you certain it's a duplicate and not just a second request? The OAuth flow involves exchanging the 3rd party tokens for that of AWS, so that you can make direct service calls from the browser. Are the requests identical? |
@reggiepangilinan You wont be able to await @seanbecker15 can you trying cleaning your modules and install the library latest |
@elorzafe yeah, I updated that part of the code. I just redirect to the callback page. One is
And the other one is
|
As I was testing out #6146 I experienced the same problem after signing in with Google: The second calls is missing Removing |
Also experiencing this when using Auth.federatedSignIn({provider: 'Google'}) unfortunately. |
Exactly same issue when trying to sign in using google federated SignIN |
Stuck with the same issue. Any Idea on the root cause? |
For clarification, did the sign in flow work at least? As in, even though a 2nd call happened with an error in the console, was the user at least signed in correctly? (It was in my testing, but want to confirm if this is breaking or not) |
Yes , the user is signed in sometimes. Sometimes the user needs to refresh
while sometimes the user is automatically logged in . Basically sign in
experience is not consistent
…On Sat, Sep 12, 2020 at 12:34 AM Eric Clemmons ***@***.***> wrote:
For clarification, did the sign in flow work at least? As in, even though
a 2nd call happened with an error in the console, was the user at least
signed in correctly?
(It was in my testing, but want to confirm if this is breaking or not)
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#6330 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AE5UPKIOC6A2R6MQO2F7H3LSFJYEFANCNFSM4O2G7IXA>
.
|
Seeing the same issue. There are two requests to oauth2/token on custom domain and 2nd POST request doesn't have code_verifier. |
@twvik @vidhyasagarj @Alk3m1st @reggiepangilinan @seanbecker15 I am only seeing one request, this are the steps I went thru.
import React from 'react';
import './App.css';
import { Amplify } from '@aws-amplify/core';
import { Auth, CognitoHostedUIIdentityProvider } from '@aws-amplify/auth';
import awsconfig from './aws-exports';
Amplify.configure(awsconfig);
function App() {
React.useEffect(() => {
(async () => {
const userInfo = await Auth.currentUserInfo();
console.log({userInfo});
})();
})
function hostedUISignIn() {
Auth.federatedSignIn({provider: CognitoHostedUIIdentityProvider.Google});
}
return (
<div className="App">
<header className="App-header">
<button onClick={hostedUISignIn}>sign in with hosted ui</button>
</header>
</div>
);
}
export default App;
const awsmobile = {
"aws_project_region": "us-west-2",
"aws_cognito_identity_pool_id": "us-west-2:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx",
"aws_cognito_region": "us-west-2",
"aws_user_pools_id": "us-west-2_xxxxxxxx",
"aws_user_pools_web_client_id": "xxxxxxxxxx",
"oauth": {
"domain": "xxxxxxxxxxx-xxxxxxxxxx-dev.auth.us-west-2.amazoncognito.com",
"scope": [
"phone",
"email",
"openid",
"profile",
"aws.cognito.signin.user.admin"
],
"redirectSignIn": "http://localhost:3000/",
"redirectSignOut": "http://localhost:3000/",
"responseType": "code"
},
"federationTarget": "COGNITO_USER_POOLS"
};
export default awsmobile; |
I have same problem. |
I can confirm I am experiencing the same issue... @ericclemmons thanks for the great work you've been doing. I have been following it from the sidelines! Using Next.js
Amplify.configure(amplifyConfig);
function MyApp({ Component, pageProps }) {
...
useEffect(() => {
dispatch(getCurrentUser()); // simply a redux action which does: const { Auth } = withSSRContext(); const res = await Auth.currentAuthenticatedUser();
Hub.listen('auth', ({ payload: { event, data } }) => {
switch (event) {
case 'signIn': {
console.log('APP::Hub::Login', data);
break;
}
case 'signOut':
console.log('APP::Hub::SignOut', data);
break;
default:
break;
}
});
}, []);
export default {
Auth: {
region: 'eu-east-1',
userPoolId: process.env.USER_POOL_ID,
userPoolWebClientId: process.env.USER_POOL_CLIENT_ID,
mandatorySignIn: true,
cookieStorage: {
domain: 'http://localhost:3000/',
path: '/',
expires: 120,
secure: 'false',
},
oauth: {
domain: 'xxxx-xxxx.auth.us-east-1.amazoncognito.com',
scope: ['email', 'profile', 'phone', 'openid'],
redirectSignIn: 'http://localhost:3000/profile',
redirectSignOut: 'http://localhost:3000/,
responseType: 'code',
},
federationTarget: 'COGNITO_USER_POOLS',
},
ssr: true,
}; when user clicks export const continueWithFacebook = () => async dispatch => {
try {
dispatch({ type: CONTINUE_WITH_REQUEST });
const { Auth } = withSSRContext();
Auth.federatedSignIn({ provider: 'Facebook' });
} catch (err) {
dispatch({ type: CONTINUE_WITH_FAILURE, payload: { error: err } });
}
}; I do see the first request being successful and the next one request simply returning from the console I can see that the Hub Listener detects the user singing in Refreshing the page removes everything under the cookie storage and the user is not persistent. Any pointers would be really helpful, or if anyone has found a workaround, that would also help. Maybe I can move on to different parts of my app and circle back to this once there is a solution... Thanks! |
Guys do we have any updates on this ? Experiencing same troubles with Angular application |
I was having the same issue in VueJS. I found another article that suggested calling |
Thanks, @Jwb81, I don't have time to dig any deeper, I just wanted to see if it looked like bypassing |
I am certain I am not calling |
Closing, as #7718 (via To install the latest version of npm install aws-amplify @aws-amplify/ui-angular
# or
yarn add aws-amplify @aws-amplify/ui-angular Be sure to install Let us know if you experience any issues! 🙏 |
@ericclemmons Has that pull request been deployed? I am wondering if I should expect the extra call to /token to still be happening or if it's already deployed, what version I should be using so that this issue goes away? At the moment for me, I still have to do @Jwb81's suggestion involving just calling Auth.configure and API.configure instead of Amplify.configure. This doesn't actually stop the /token endpoint from being called twice (and failing the second), but it does prevent the behavior described by @slatemates here. Edit |
@ericclemmons I am still having the same error and I am not sure what the ui-angular package has to do with that, here is the code that causes Auth double initialisation: https://github.com/aws-amplify/amplify-js/blob/main/packages/auth/src/Auth.ts#L2201 . So Auth is always configured twice which results in duplicate token request in case of federated sign in. |
I encountered this issue while using This causes dependencies inside Unfortunately, at the time of writing, there is not a simple resolution. |
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs. Looking for a help forum? We recommend joining the Amplify Community Discord server |
Describe the bug
A clear and concise description of what the bug is.
I have a react app that is using a custom login page. Which calls Google for federated signin.
When I try to login using Google. The behaviour of
Auth.federatedSignIn
is unpredictable.Sometimes it succeeds sometimes it fails
I checked all of these but it did not fix my issue
#3642
#3185 (comment)
#6041
#5829
#6172
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
I was hoping after the federated signin using
I can just set my currentUser in my global context
Code Snippet
Please provide a code snippet or a link to sample code of the issue you are experiencing to help us reproduce the issue. (Be sure to remove any sensitive data)
This basically how is signin using google
Screenshots
If applicable, add screenshots to help explain your problem.
Checkout this screenshot
What is Configured?
If applicable, please provide what is configured for Amplify CLI:
amplify add auth
aws-exports
file:const awsmobile = {
"aws_project_region": "ap-southeast-2",
"aws_cognito_identity_pool_id": "ap-southeast-2:9f419afd-8e58-42e0-a5be-2f6ae54ef525",
"aws_cognito_region": "ap-southeast-2",
"aws_user_pools_id": "ap-southeast-2_MTlyh2uhv",
"aws_user_pools_web_client_id": "4vhitjj2i7egv4v44nohgpedb0",
"oauth": {
"domain": "mycirclesbc57058d-bc57058d-dev.auth.ap-southeast-2.amazoncognito.com",
"scope": [
"phone",
"email",
"openid",
"profile",
"aws.cognito.signin.user.admin"
],
"redirectSignIn": "http://localhost:3031/",
"redirectSignOut": "http://localhost:3031/",
"responseType": "code"
},
"federationTarget": "COGNITO_USER_POOLS"
};
aws cognito-idp describe-user-pool --user-pool-id us-west-2_xxxxxx
(Be sure to remove any sensitive data)Environment
System:
OS: macOS 10.15.5
CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
Memory: 691.59 MB / 16.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 10.15.3 - /usr/local/bin/node
Yarn: 1.13.0 - /usr/local/bin/yarn
npm: 6.14.6 - ~/dev/mycircles/node_modules/.bin/npm
Watchman: 4.7.0 - /usr/local/bin/watchman
Browsers:
Chrome: 83.0.4103.116
Safari: 13.1.1
npmPackages:
@aws-amplify/ui-react: ^0.2.10 => 0.2.10
@storybook/addon-actions: ^5.3.19 => 5.3.19
@storybook/addon-links: ^5.3.19 => 5.3.19
@storybook/addons: ^5.3.19 => 5.3.19
@storybook/preset-create-react-app: ^3.1.3 => 3.1.3
@storybook/react: ^5.3.19 => 5.3.19
@storybook/theming: ^5.3.19 => 5.3.19
@testing-library/jest-dom: ^4.2.4 => 4.2.4
@testing-library/react: ^9.3.2 => 9.5.0
@testing-library/user-event: ^7.1.2 => 7.2.1
@types/jest: ^24.0.0 => 24.9.1
@types/node: ^12.0.0 => 12.12.48
@types/react: ^16.9.0 => 16.9.41
@types/react-dom: ^16.9.0 => 16.9.8
@types/react-router-dom: ^5.1.5 => 5.1.5
@types/yup: ^0.29.3 => 0.29.3
@typescript-eslint/eslint-plugin: ^3.6.0 => 3.6.0
@typescript-eslint/parser: ^3.6.0 => 3.6.0
aws-amplify: ^3.0.20 => 3.0.20
eslint-config-prettier: ^6.11.0 => 6.11.0
eslint-config-react: ^1.1.7 => 1.1.7
eslint-plugin-prettier: ^3.1.4 => 3.1.4
formik: ^2.1.4 => 2.1.4
import-sort-style-module: ^6.0.0 => 6.0.0
install: ^0.13.0 => 0.13.0
node-sass: ^4.14.1 => 4.14.1
npm: ^6.14.6 => 6.14.6
plop: ^2.7.1 => 2.7.1
prettier: ^2.0.5 => 2.0.5
prettier-plugin-import-sort: 0.0.4 => 0.0.4
react: ^16.13.1 => 16.13.1
react-dom: ^16.13.1 => 16.13.1
react-icons: ^3.10.0 => 3.10.0
react-router-dom: ^5.2.0 => 5.2.0
react-scripts: 3.4.1 => 3.4.1
react-use: ^15.3.2 => 15.3.2
typescript: ~3.7.2 => 3.7.5
yup: ^0.29.1 => 0.29.1
npmGlobalPackages:
@angular/cli: 1.7.3
@aws-amplify/cli: 4.24.1
angular-cli-ghpages: 0.5.2
babel-cli: 6.11.4
babel-eslint: 6.1.2
bower: 1.7.9
create-react-library: 2.6.7
create-react-native-app: 1.0.0
eslint-plugin-meteor: 4.0.0
eslint-plugin-react: 6.0.0
eslint: 3.2.2
exp: 49.0.1
gatsby-cli: 2.11.5
generator-hottowel: 0.4.1
generator-rn-toolbox: 2.0.10
gulp: 3.9.1
ignite-cli: 2.0.0-beta.8
mantra-cli: 0.4.0-rc.4
mocha: 3.0.1
modus-ui: 0.0.15
nodemon: 1.9.2
npm: 6.4.1
react-native-cli: 2.0.1
swagger: 0.7.5
tsd: 0.6.5
typescript: 1.8.10
typings: 1.3.0
yo: 1.8.5
Smartphone (please complete the following information):
Additional context
Add any other context about the problem here.
You can turn on the debug mode to provide more info for us by setting window.LOG_LEVEL = 'DEBUG'; in your app.
The text was updated successfully, but these errors were encountered: