aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.44k stars 2.13k forks source link

signInWithRedirect has no effect after login #13904

Closed MensurRasic closed 3 weeks ago

MensurRasic commented 1 month ago

Before opening, please confirm:

JavaScript Framework

Next.js

Amplify APIs

Authentication

Amplify Version

v6

Amplify Categories

auth

Backend

Amplify Gen 2 (Preview)

Environment information

``` Binaries: Node: 20.9.0 - /usr/local/bin/node npm: 10.1.0 - /usr/local/bin/npm Watchman: 2023.12.04.00 - /opt/homebrew/bin/watchman Browsers: Chrome: 129.0.6668.100 Safari: 17.6 npmPackages: @ampproject/toolbox-optimizer: undefined () @auth0/auth0-react: ^2.2.3 => 2.2.3 @aws-amplify/ui-react-storage: ^3.1.3 => 3.1.3 @babel/runtime: 7.22.5 @edge-runtime/cookies: 4.0.2 @edge-runtime/ponyfill: 2.4.1 @edge-runtime/primitives: 4.0.2 @types/autosuggest-highlight: ^3.2.3 => 3.2.3 @types/google-map-react: ^2.1.10 => 2.1.10 @types/google.maps: ^3.55.5 => 3.55.5 @types/lodash: ^4.14.202 => 4.14.202 @types/mapbox-gl: ^2.7.21 => 2.7.21 @types/node: ^20.10.4 => 20.10.4 @types/nprogress: ^0.2.3 => 0.2.3 @types/react: ^18.2.43 => 18.2.43 @types/react-lazy-load-image-component: ^1.6.3 => 1.6.3 @types/react-slick: ^0.23.12 => 0.23.12 @types/stylis: ^4.2.4 => 4.2.4 @typescript-eslint/eslint-plugin: ^6.13.2 => 6.13.2 @typescript-eslint/parser: ^6.13.2 => 6.13.2 @vercel/nft: undefined () @vercel/og: 0.5.15 aws-amplify: ^6.6.4 => 6.6.4 axios: ^1.6.2 => 1.6.8 client-only: 0.0.1 eslint: ^8.55.0 => 8.55.0 framer-motion: ^10.16.16 => 10.16.16 net: ^1.0.2 => 1.0.2 next: ^14.0.4 => 14.0.4 react: ^18.2.0 => 18.2.0 react-dom: ^18.2.0 => 18.2.0 react-dom-builtin: undefined () typescript: ^5.3.3 => 5.3.3 npmGlobalPackages: corepack: 0.20.0 npm: 10.1.0 react-devtools: 5.0.0 ```

Describe the bug

When I try to login with a provider such as google, using await signInWithRedirect({ provider: 'Google' });, the nextjs project is stuck at the moment I'm calling await getCurrentUser() right after I get redirected back to the project.

I don't get any error triggered in my try catch nor the project doesn't want to continue the login process.

Here's my Amplify config : Amplify.configure( { ...awsconfig, oauth: { ...awsconfig.oauth, redirectSignIn: 'http://localhost:8082/dashboard/', redirectSignOut: 'http://localhost:8082/', }, }, { ssr: true } );

I tried the following solutions but none of them works : 12873, 13456, 13472

Expected behavior

The user should be able to complete the login process using the authentication with google sign-in.

Reproduction steps

Setup a nextjs project with aws-amplify: ^6.6.4 and setup a google authentication. Try to login with the google authentication to the project.

Code Snippet

// Put your code below this line.

Log output

``` // Put your logs below this line ```

aws-exports.js

No response

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

ashika112 commented 1 month ago

@MensurRasic Thanks for reaching out. Just wanted to confirm are you following our docs here already for building up your app?

MensurRasic commented 1 month ago

Yes I did, but the documentation you shared is for Gen 1, I’m on Gen 2. But I followed Gen 2 documentation as well and it’s still not working.

cwomack commented 1 month ago

@MensurRasic, can you confirm that you're importing the import 'aws-amplify/auth/enable-oauth-listener'; on the client side page where your redirect for http://localhost:8082/dashboard/ is? Also, any frontend code you can provide for your authentication flows would be helpful for us to better identify the root cause here.

cwomack commented 3 weeks ago

Closing this issue as we have not heard back from you. If you are still experiencing this, please feel free to reply back and provide any information previously requested and we'd be happy to re-open the issue.

Thank you!