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.42k stars 2.11k forks source link

SigningWithRedirect, custom provider, requires two login attempts to work - ANDROID #13774

Closed milicaNano closed 1 week ago

milicaNano commented 1 week ago

Before opening, please confirm:

JavaScript Framework

React Native

Amplify APIs

Authentication

Amplify Version

v6

Amplify Categories

auth

Backend

Other

Environment information

System: OS: macOS 14.4.1 CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz Memory: 941.37 MB / 16.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 20.12.0 - /usr/local/bin/node Yarn: 1.22.17 - /usr/local/bin/yarn npm: 10.5.0 - /usr/local/bin/npm Watchman: 2024.01.22.00 - /usr/local/bin/watchman Browsers: Chrome: 128.0.6613.114 Safari: 17.4.1 npmPackages: @aws-amplify/react-native: ^1.0.13 => 1.1.4 @aws-amplify/rtn-web-browser: ^1.0.13 => 1.0.31 @aws-amplify/ui-react-native: 2.2.2 => 2.2.2 @babel/core: ^7.20.0 => 7.25.2 @babel/preset-env: ^7.20.0 => 7.25.4 @babel/runtime: ^7.20.0 => 7.25.6 @gorhom/bottom-sheet: ^4.6.1 => 4.6.4 @gorhom/portal: ^1.0.14 => 1.0.14 @react-native-async-storage/async-storage: ^1.21.0 => 1.24.0 @react-native-community/blur: ^4.4.0 => 4.4.1 @react-native-community/netinfo: ^11.3.1 => 11.3.2 @react-native-community/slider: ^4.5.0 => 4.5.2 @react-native-firebase/app: ^19.0.1 => 19.3.0 @react-native-firebase/crashlytics: ^19.0.1 => 19.3.0 @react-native-masked-view/masked-view: ^0.3.1 => 0.3.1 @react-native/babel-preset: 0.73.19 => 0.73.19 @react-native/eslint-config: 0.73.2 => 0.73.2 @react-native/metro-config: 0.73.3 => 0.73.3 @react-native/typescript-config: 0.73.1 => 0.73.1 @react-navigation/native: ^6.1.9 => 6.1.18 @react-navigation/native-stack: ^6.9.17 => 6.11.0 @reduxjs/toolkit: ^2.1.0 => 2.2.7 @reduxjs/toolkit-query: 1.0.0 @reduxjs/toolkit-query-react: 1.0.0 @reduxjs/toolkit-react: 1.0.0 @types/luxon: ^3.4.2 => 3.4.2 @types/react: ^18.2.6 => 18.3.5 @types/react-test-renderer: ^18.0.0 => 18.3.0 HelloWorld: 0.0.1 aws-amplify: ^6.0.13 => 6.5.3 aws-amplify/adapter-core: 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/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 () babel-jest: ^29.6.3 => 29.7.0 buffer: ^6.0.3 => 6.0.3 (4.9.2, 5.7.1) dayjs: ^1.11.11 => 1.11.13 defu: ^6.1.4 => 6.1.4 deprecated-react-native-prop-types: ^5.0.0 => 5.0.0 (2.3.0) eslint: ^8.19.0 => 8.57.0 example: 0.0.1 i18next: ^23.11.5 => 23.14.0 immer: ^10.0.3 => 10.1.1 (9.0.6) intl-pluralrules: ^2.0.1 => 2.0.1 jest: ^29.6.3 => 29.7.0 jotai: ^2.8.0 => 2.9.3 lodash: ^4.17.21 => 4.17.21 lodash.set: ^4.3.2 => 4.3.2 lottie-react-native: ^6.5.1 => 6.7.2 luxon: ^3.4.4 => 3.5.0 patch-package: ^8.0.0 => 8.0.0 prettier: 2.8.8 => 2.8.8 (3.3.3) react: 18.2.0 => 18.2.0 react-i18next: ^14.1.1 => 14.1.3 react-native: 0.73.2 => 0.73.2 react-native-animate-number: ^0.1.2 => 0.1.2 react-native-bootsplash: ^5.3.0 => 5.5.3 react-native-code-push: ^8.2.1 => 8.3.1 react-native-config: ^1.5.1 => 1.5.3 react-native-device-info: ^10.12.0 => 10.14.0 react-native-document-picker: ^9.1.1 => 9.3.1 react-native-dotenv: ^3.4.10 => 3.4.11 react-native-fast-image: ^8.6.3 => 8.6.3 react-native-flipper: ^0.164.0 => 0.164.0 react-native-gesture-handler: ^2.15.0 => 2.19.0 react-native-get-random-values: ^1.10.0 => 1.11.0 react-native-image-picker: ^7.1.0 => 7.1.2 react-native-keyboard-spacer: ^0.4.1 => 0.4.1 react-native-linear-gradient: ^2.8.3 => 2.8.3 react-native-localize: ^3.1.0 => 3.2.1 react-native-onesignal: ^5.1.0 => 5.2.3 react-native-orientation-locker: ^1.7.0 => 1.7.0 react-native-permissions: ^4.1.5 => 4.1.5 react-native-reanimated: 3.11.0 => 3.11.0 react-native-restart: ^0.0.27 => 0.0.27 react-native-safe-area-context: ^4.8.2 => 4.10.9 react-native-screens: ^3.29.0 => 3.34.0 react-native-sound-player: ^0.14.3 => 0.14.3 react-native-store-version: ^1.4.1 => 1.4.1 react-native-svg: ^15.1.0 => 15.6.0 react-native-url-polyfill: ^2.0.0 => 2.0.0 react-native-ux-cam: ^5.4.15 => 5.4.16 react-native-vector-icons: ^10.0.3 => 10.1.0 react-native-video: ^6.4.2 => 6.4.5 react-native-video-player: ^0.14.0 => 0.14.0 react-native-vision-camera: ^4.5.1 => 4.5.2 react-native-webview: ^13.8.1 => 13.12.1 react-redux: ^7.2.6 => 7.2.9 react-test-renderer: 18.2.0 => 18.2.0 redux: ^4.2.1 => 4.2.1 (5.0.1) redux-devtools-extension: ^2.13.9 => 2.13.9 redux-flipper: ^2.0.2 => 2.0.3 redux-thunk: ^2.4.0 => 2.4.2 (3.1.0) remote-redux-devtools: ^0.5.16 => 0.5.16 socket.io-client: ^4.7.4 => 4.7.5 typescript: 5.0.4 => 5.0.4 npmGlobalPackages: code-push-cli: 3.0.0 corepack: 0.25.2 npm: 10.5.0 sass: 1.60.0 yarn: 1.22.17

Describe the bug

Sign in with redirect , with custom provider (Octa), does not redirect to authenticated page in React Native app. On Andorid devices, after you submit Octa credentials, it redirects you again to non-authenticated page and fails to switch to authenticated page. You must click again on button that handles SSO in order to be redirected to authenticated page.

We saw the issue https://github.com/aws-amplify/amplify-js/issues/12926 and we tried with package update : [aws-amplify@6.4.3] but still it doesn't work

This is always working on IOS.

Expected behavior

Clicking on continue with SSO will leave user on third party page After user submits credentials, user will be redirected to authenticated page, not again on login page

Reproduction steps

https://github.com/user-attachments/assets/bcf5cd69-bea5-43ca-b453-23abadbe06c8

Code Snippet

  function handleSignInClick() {
    setError('');
    signInWithRedirect({
      provider: {
        custom: 'Okta',
      },
      options: {
        preferPrivateSession: true,
      },
    }).catch(e => {
      const errorMessage = e.message.trim();
      if (errorMessage === 'Invalid SAML response received: PreSignUp failed with error UserNotFoundException.') {
        setError(t('nonExistSSOuser'));
      } else {
        setError(getErrorMessage(e));
      }
    });
  }

Log output

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

aws-exports.js

No response

Manual configuration

Amplify.configure({
  API: {
    REST: {
      core: {
        endpoint: process.env.REACT_APP_API_URL,
      },
    },
  },
  Auth: {
    Cognito: {
      userPoolClientId: process.env.USER_POOL_CLIENT_ID,
      userPoolId: process.env.USER_POOL_ID,
      loginWith: {
        email: true,
        oauth: {
          domain: 'qa-nano-pepsico-mexico.auth.us-east-1.amazoncognito.com',
          redirectSignIn: ['com.nanopepsico://callback'],
          redirectSignOut: ['com.nanopepsico://logout'],
          responseType: 'code',
          scopes: ['openid', 'profile', 'email'],
          providers: [
            {
              custom: 'Okta',
            },
          ],
        },
      },
    },
  },
});

Additional configuration

No response

Mobile Device

Android Galaxy S24 Ultra

Mobile Operating System

Android version 14

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

cwomack commented 1 week ago

Hello, @milicaNano and thanks for creating this issue. The signInWithRedirect fix should be implemented as of v6.4.3 (as you stated and tried), but just to double check on this... can you make sure you delete your package-lock.json file, delete your node_modules directory, and try reinstalling your dependencies with npm install (or yarn equivalent)? And can you also try to delete your cache by running the following command:

yarn start --reset-cache

If it's still happening after this, can you let us know if this is happening in dev, prod, or both environments as well? Thanks!

milicaNano commented 1 week ago

Thanks @cwomack. With your detailed steps, seems to be working. We are still conduction tests, as this was not reproducible on all Android devices. I will share feedback soon. Many thanks.

milicaNano commented 1 week ago

Two days testing on production, and seems to be working. We can close this issue.

Many thanks!