amplify-js: Auth with react native not working anymore, An unknown error has ocurred.

Before opening, please confirm:

JavaScript Framework

React Native

Amplify APIs

Authentication

Amplify Categories

auth

Environment information

 System:
    OS: macOS 14.1.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 80.91 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.3.1 - ~/homebrew/bin/node
    Yarn: 1.22.19 - ~/homebrew/bin/yarn
    npm: 9.6.7 - ~/homebrew/bin/npm
  Browsers:
    Chrome: 112.0.5615.49
    Safari: 17.1
  npmPackages:
    @aws-amplify/react-native: ^1.0.5 => 1.0.5 
    @aws-amplify/rtn-web-browser: 1.0.3 => 1.0.3 
    @aws-amplify/ui-react-native: ^2.0.3 => 2.0.3 
    @babel/core: ^7.20.0 => 7.23.3 
    @expo-google-fonts/inter: ^0.2.3 => 0.2.3 
    @expo/ngrok: ^4.1.3 => 4.1.3 
    @expo/vector-icons: ^13.0.0 => 13.0.0 
    @react-native-async-storage/async-storage: 1.18.2 => 1.18.2 
    @react-native-community/netinfo: 9.3.10 => 9.3.10 
    @react-navigation/native: ^6.0.2 => 6.1.9 
    @types/react: ~18.2.14 => 18.2.37 
    HelloWorld:  0.0.1 
    amazon-cognito-identity-js: ^6.3.7 => 6.3.7 
    amazon-cognito-identity-js/internals:  undefined ()
    aws-amplify: ^6.0.5 => 6.0.5 
    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/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 ()
    clsx: ^2.0.0 => 2.0.0 
    expo: ~49.0.15 => 49.0.19 
    expo-auth-session: ~5.0.2 => 5.0.2 
    expo-font: ~11.4.0 => 11.4.0 
    expo-image-picker: ~14.3.2 => 14.3.2 
    expo-linking: ~5.0.2 => 5.0.2 
    expo-router: ^2.0.0 => 2.0.13 
    expo-splash-screen: ~0.20.5 => 0.20.5 
    expo-status-bar: ~1.6.0 => 1.6.0 
    expo-system-ui: ~2.4.0 => 2.4.0 
    expo-updates: ~0.18.17 => 0.18.17 
    expo-web-browser: ~12.3.2 => 12.3.2 
    jest: ^29.2.1 => 29.7.0 
    jest-expo: ~49.0.0 => 49.0.0 
    nativewind: ^2.0.11 => 2.0.11 
    react: 18.2.0 => 18.2.0 
    react-dom: 18.2.0 => 18.2.0 
    react-native: 0.72.6 => 0.72.6 
    react-native-gesture-handler: ~2.12.0 => 2.12.1 
    react-native-get-random-values: ~1.9.0 => 1.9.0 
    react-native-safe-area-context: 4.6.3 => 4.6.3 
    react-native-screens: ~3.22.0 => 3.22.1 
    react-native-web: ~0.19.6 => 0.19.9 
    react-test-renderer: 18.2.0 => 18.2.0 
    tailwindcss: 3.3.2 => 3.3.2 
    typescript: ^5.1.3 => 5.2.2 
  npmGlobalPackages:
    @expo/ngrok: 4.1.3
    auth0-deploy-cli: 7.17.7
    eas-cli: 5.9.1
    gatsby: 5.12.5
    npm-check-updates: 16.14.6
    npm: 9.6.7


Describe the bug

Using the signin method of amplify is not working anymore and throws [Unknown: An unknown error has ocurred.]

Expected behavior

It should login the user

Reproduction steps

  1. Follow the steps from the tutorial
  2. Configure amplify
  3. the login does not work in react native but works in my web backoffice

(4. I tried with the amplify UI as well and the same error occurs)

Code Snippet


Amplify.configure({
  Auth: {
    Cognito: {
      userPoolId: '_',
      userPoolClientId: '_',
    },
  },
});

cognitoUserPoolsTokenProvider.setKeyValueStorage(defaultStorage);


export default function Login() {
  const [username, setUsername] = useState('');
  const [password, setPassword] = useState('');

  async function handleSignIn({ username, password }: SignInInput) {
    console.log(username, password);
    try {
      const { isSignedIn, nextStep } = await signIn({ username, password });
    } catch (error) {
      console.log('error signing in', error);
    }
  }

  return (
    <SafeAreaView>
      <View className='flex h-full w-full px-6 '>
        <View className='flex mt-4'>
          <Text className='text-3xl font-bold'>Se connecter</Text>
          <Text className='text-gray-600 mt-2 text-base'>
            Pour vous connecter, renseignez le mail et votre mot
            de passe.
          </Text>
        </View>
        <View className='w-full mt-4'>
          <Text className='text-gray-500 mb-1 text-base'>Email</Text>
          <TextInput
            className='lowercase w-full border border-gray-300 rounded p-2 placeholder:text-base'
            keyboardType='email-address'
            placeholder='test@test.com'
            onChange={(e) => setUsername(e.nativeEvent.text.toLowerCase())}
          />
        </View>
        <View className='w-full mt-4 mb-4'>
          <Text className='text-gray-500 mb-1 text-base'>Mot de passe</Text>
          <TextInput
            className='w-full border border-gray-300 rounded p-2 text-base placeholder:text-base'
            placeholder='Mot de passe'
            secureTextEntry={true}
            onChange={(e) => setPassword(e.nativeEvent.text)}
          />
        </View>

        {error && <Text className='text-red-500 text-sm mb-4'>{error}</Text>}

        <Button onPress={() => handleSignIn({ username, password })}>
          Se connecter
        </Button>
     
      </View>
    </SafeAreaView>

Log output

// Put your logs below this line


aws-exports.js

No response

Manual configuration

Amplify.configure({ Auth: { Cognito: { userPoolId: ‘', userPoolClientId: '’, }, }, });

Additional configuration

No response

Mobile Device

iPhone15

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

About this issue

  • Original URL
  • State: closed
  • Created 7 months ago
  • Comments: 21 (5 by maintainers)

Most upvoted comments

Finally!! Tried https://github.com/aws-amplify/amplify-js/issues/12622#issuecomment-1830789725 this version, and able to login. @aleguern you were also using this version?

No it’s still not working