Skip to content

Amplify AUTH - reat native - "An unknown error has occurred"

0

Hi there does anyone know why i am getting 'An unknown error has occurred" when trying to login using react native and amplify.

I had two projects working fine and all of a sudden they stopped working.

i created 2 new ones to test and no of them work but if i create a react project, auth work fine.

thank you

1 Answer
1

The "An unknown error has occurred" message you're encountering with Amplify Auth in React Native could be due to several reasons. Here are some potential causes and solutions to consider:

  1. Compatibility issues: Ensure that you're using compatible versions of AWS Amplify, React Native, and other related dependencies. Sometimes, version mismatches can cause unexpected errors.

  2. Configuration problems: Double-check your Amplify configuration, especially the auth settings. Make sure your app is correctly configured with the right Cognito User Pool and App Client ID.

  3. Private App Client with Client Secret: If you're using a Private App Client with a Client Secret, be aware that the Amplify JavaScript SDK (which React Native uses) does not support this configuration. You may need to switch to a Public App Client without a Client Secret.

  4. Outdated or corrupted dependencies: Try clearing your node_modules folder and reinstalling your dependencies. You can do this by running:

    rm -rf node_modules
    npm install
    
  5. Amplify CLI issues: Ensure your Amplify CLI is up to date and try running amplify pull to sync your local environment with the cloud backend.

  6. Network issues: Verify that your device or emulator has a stable internet connection.

  7. Amplify service disruptions: Check the AWS Service Health Dashboard to see if there are any ongoing issues with Amplify or related services.

If the problem persists after trying these solutions, you may want to enable more detailed logging in your app to get more information about the error. Additionally, reviewing your CloudWatch logs for the Cognito User Pool might provide more insights into what's causing the authentication failure.

Given that your React projects are working fine, but React Native projects are not, it's possible that there's a specific issue with the React Native implementation or its interaction with Amplify. You might want to compare the configurations and dependencies between your working React projects and the non-working React Native projects to identify any discrepancies.
Sources
How to use a private App Client ID w/ Client Secret in a React Native Mobile App | AWS re:Post
on amplify react app deploy issue | AWS re:Post

answered 2 years ago

EXPERT

reviewed 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.