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.41k stars 2.12k forks source link

Not able to login after upgrading to v6 from v4 #13261

Open gauravrana0-nagarro opened 4 months ago

gauravrana0-nagarro commented 4 months 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.3 CPU: (8) arm64 Apple M1 Memory: 107.34 MB / 8.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 20.11.1 - /opt/homebrew/opt/node@20/bin/node Yarn: 1.22.22 - /opt/homebrew/bin/yarn npm: 9.3.1 - ~/Documents/Learn/true-value-evaluator-frontend/node_modules/.bin/npm Watchman: 2024.03.25.00 - /opt/homebrew/bin/watchman Browsers: Chrome: 124.0.6367.61 Edge: 123.0.2420.97 Safari: 17.3 npmPackages: @aws-amplify/react-native: ^1.0.28 => 1.0.28 @babel/core: ^7.20.0 => 7.24.3 @babel/preset-env: ^7.20.0 => 7.20.2 @babel/runtime: ^7.20.0 => 7.20.13 @bam.tech/react-native-image-resizer: ^3.0.7 => 3.0.7 @miblanchard/react-native-slider: ^2.1.0 => 2.2.0 @react-native-async-storage/async-storage: ^1.23.1 => 1.23.1 @react-native-community/geolocation: ^3.0.3 => 3.0.5 @react-native-community/netinfo: ^11.3.1 => 11.3.1 @react-native-firebase/app: ^16.5.0 => 16.5.2 @react-native-firebase/messaging: ^16.5.0 => 16.5.2 @react-native/babel-preset: 0.73.21 => 0.73.21 @react-native/eslint-config: 0.73.2 => 0.73.2 @react-native/metro-config: 0.73.5 => 0.73.5 @react-native/typescript-config: 0.73.1 => 0.73.1 @react-navigation/bottom-tabs: ^6.3.1 => 6.5.3 @react-navigation/native: ^6.0.8 => 6.1.17 @react-navigation/native-stack: ^6.6.2 => 6.9.8 @reduxjs/toolkit: ^1.8.2 => 1.9.1 @reduxjs/toolkit-query: 1.0.0 @reduxjs/toolkit-query-react: 1.0.0 @testing-library/react-native: ^11.0.0 => 11.5.0 @types/react: ^18.2.6 => 18.2.67 (17.0.79) @types/react-native-snap-carousel: ^3.8.5 => 3.8.5 @types/react-test-renderer: ^18.0.7 => 18.0.7 HelloWorld: 0.0.1 ReactNativeBlobUtilWin: 0.0.1 aws-amplify: ^6.0.28 => 6.0.28 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 () axios: ^0.27.2 => 0.27.2 babel-jest: ^29.6.3 => 29.7.0 (27.5.1) babel-plugin-transform-class-properties: ^6.24.1 => 6.24.1 buffer: ^6.0.3 => 6.0.3 (4.9.2, 5.7.1) eslint: ^8.19.0 => 8.57.0 i: ^0.3.7 => 0.3.7 install: ^0.13.0 => 0.13.0 jail-monkey: ^2.8.0 => 2.8.0 jest: ^29.6.3 => 29.7.0 (27.5.1) libphonenumber-js: ^1.10.14 => 1.10.18 libphonenumber-js/build: undefined () libphonenumber-js/core: undefined () libphonenumber-js/max: undefined () libphonenumber-js/max/metadata: undefined () libphonenumber-js/min: undefined () libphonenumber-js/min/metadata: undefined () libphonenumber-js/mobile: undefined () libphonenumber-js/mobile/examples: undefined () libphonenumber-js/mobile/metadata: undefined () lodash: ^4.17.21 => 4.17.21 moment: ^2.29.4 => 2.29.4 npm: ^9.2.0 => 9.3.1 prettier: 2.8.8 => 2.8.8 react: 18.2.0 => 18.2.0 react-native: ^0.73.0 => 0.73.6 react-native-android-location-services-dialog-box: ^2.8.2 => 2.8.2 react-native-blob-util: ^0.16.2 => 0.16.4 react-native-chart-kit: ^6.12.0 => 6.12.0 react-native-date-picker: ^4.2.5 => 4.2.6 react-native-device-info: ^10.3.0 => 10.3.0 react-native-fs: ^2.18.0 => 2.20.0 react-native-gesture-handler: ^2.14.0 => 2.15.0 react-native-get-random-values: ^1.11.0 => 1.11.0 react-native-image-crop-picker: ^0.38.0 => 0.38.1 react-native-image-zoom-viewer: ^3.0.1 => 3.0.1 react-native-iphone-x-helper: ^1.3.1 => 1.3.1 react-native-keep-awake: ^4.0.0 => 4.0.0 react-native-keyboard-aware-scroll-view: ^0.9.5 => 0.9.5 react-native-linear-gradient: ^2.6.2 => 2.6.2 react-native-maps: 1.3.2 => 1.3.2 react-native-maps-directions: 1.9.0 => 1.9.0 react-native-month-year-picker: ^1.9.0 => 1.9.0 react-native-pdf: ^6.6.2 => 6.6.2 react-native-responsive-screen: ^1.4.2 => 1.4.2 react-native-restart: ^0.0.27 => 0.0.27 react-native-safe-area-context: ^4.8.2 => 4.9.0 react-native-screens: ^3.28.0 => 3.29.0 react-native-simple-toast: ^1.1.3 => 1.1.4 react-native-size-matters: ^0.4.0 => 0.4.0 react-native-snap-carousel: ^3.9.1 => 3.9.1 react-native-svg: ^14.0.0 => 14.1.0 react-native-vision-camera: ^3.9.2 => 3.9.2 react-native-zip-archive: ^6.0.9 => 6.0.9 react-redux: ^8.0.2 => 8.0.5 react-scripts: ^5.0.1 => 5.0.1 react-test-renderer: 18.2.0 => 18.2.0 redux-persist: ^6.0.0 => 6.0.0 redux-persist/integration/react: undefined () responsive-screen: 0.1.0 responsive-screen-orientation-change: 0.1.0 responsive-screen-styled-components: 0.1.0 ts-jest: ^28.0.7 => 28.0.8 typescript: 5.0.4 => 5.0.4 npmGlobalPackages: @aws-amplify/cli: 12.11.0 corepack: 0.23.0 npm: 10.2.4 ```

Describe the bug

While upgrading my react-native project from 0.68.2 to 0.73 I upgraded aws-amplify version also from v4 t v6 as v4 was working fine with iOS RN version 0.73 but was giving error in android. I removed amazon-cognito-identity-js package as it was giving duplicate code error in iOS. After making this change and installing the lastest aws packages my code now is now stuck at line "Amplify.configure({ Auth: LoginClient.auth });"

Expected behavior

It should authenticate and proceed.

Reproduction steps

1 Installed npm install @aws-amplify/ui-react-native aws-amplify @aws-amplify/react-native react-native-safe-area-context @react-native-community/netinfo @react-native-async-storage/async-storage react-native-get-random-values

  1. cd ios && pod install
  2. npm start
  3. npx react-native run-ios. or npx react-native run-android the app is stuck on login screen

Code Snippet

// Put your code below this line.
import { Auth , Amplify} from 'aws-amplify';
 LoginClient.auth = {
      region: data.region,
      userPoolId: data.userPoolId,
      userPoolWebClientId: data.userPoolWebClientId,
      authenticationFlowType: data.authenticationFlowType || 'CUSTOM_AUTH',
      federationDomain: data.domain,
      oauth: {
        domain: data.authServer,
        scope: ['email', 'openid', 'aws.cognito.signin.user.admin', 'profile'],
        responseType: 'code',
      },
    };
 Amplify.configure({ Auth: LoginClient.auth });

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

cwomack commented 4 months ago

Hello, @gauravrana0-nagarro 👋. Are you trying to use OAuth with this iOS app? It looks like you might be missing the @aws-amplify/rtn-web-browser package if so, which you can see the docs for here. Also, are you using the Authenticator or just the regular Auth API's for signing in to your federated provider?

Any sample code tied to your authentication flow might be helpful as well. Thanks!

gauravrana0-nagarro commented 4 months ago

Hello @cwomack , we are using OAuth in v4 in a react native project. But it is not working after upgrading to v6. If I don't upgrade v4 to v6 will v4 work with the react-native version 0.73 ?