Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

React Native AWS Amplify AuthError : Amplify has not been configured correctly

$
0
0

I'm using AWS Amplify library in my react native project with manual configuration to sign in. I'm able to login in android application with react native project, but when i run the same react native code in ios, i'm getting the below error. I'm fetching my amplify configuration params data from .env files in react native.

I have followed these steps for iOS pod install for setting up the Amplify libraryhttps://docs.amplify.aws/lib/auth/start/q/platform/js#configure-your-application

I have installed all the pods in iOS related to https://www.npmjs.com/package/react-native-config and amplify libraries.

// import Amplify, { Auth } from 'aws-amplify';   import Amplify from '@aws-amplify/core';   import Auth from '@aws-amplify/auth';  /** Configration of Cognito Auth Process for mobile client */    Amplify.configure({      Auth: {  // REQUIRED only for Federated Authentication - Amazon Cognito Identity Pool ID  identityPoolId: Config.REACT_APP_AWS_COGNITO_IDENTITY_POOL_ID,  // REQUIRED - Amazon Cognito Region  region:  Config.REACT_APP_AWS_COGNITO_REGION,  // OPTIONAL - Amazon Cognito User Pool ID  userPoolId: Config.REACT_APP_AWS_COGNITO_USER_POOL_ID,  // OPTIONAL - Amazon Cognito Web Client ID (26-char alphanumeric string)  userPoolWebClientId: Config.REACT_APP_AWS_COGNITO_USER_POOL_WEB_CLIENT_ID,  // OPTIONAL - Enforce user authentication prior to accessing AWS resources or not  mandatorySignIn: false,  // OPTIONAL - Manually set the authentication flow type. Default is 'USER_SRP_AUTH'  authenticationFlowType: 'USER_PASSWORD_AUTH',   // OPTIONAL - Hosted UI configuration  oauth: {      domain: Config.REACT_APP_AWS_COGNITO_OAUTH_DOMAIN,      scope: ['openid', 'aws.cognito.signin.user.admin'],      redirectSignIn: Config.REACT_APP_AWS_COGNITO_OAUTH_REDIRECT_SIGNIN,      redirectSignOut: Config.REACT_APP_AWS_COGNITO_OAUTH_REDIRECT_SIGNOUT,      responseType: Config.REACT_APP_AWS_COGNITO_OAUTH_RESPONSE_TYPE, // or 'token', note       that REFRESH token will only be generated when the responseType is code     }     }.      });   // You can get the current config object    const currentConfig = Auth.configure();  //Usage   Auth.signIn(username, password).then(    (result) => {      console.log(result);      if(result instanceof CognitoUser){        console.log(result.getSignInUserSession()?.getAccessToken().getJwtToken());        console.log(result.getSignInUserSession()?.getIdToken());        console.log(result.getSignInUserSession()?.getRefreshToken());      }      this.props.navigation.replace('ChangePassword');    }  ).catch(    (error) => {      console.log('################# SignIn Error :');      console.log(error);    }  )   } catch (exception) {  console.log(exception);     console.log('################# Exception in SignIn API call');    }

Not able to figure out what was the issue.

 [ERROR] 27:54.153 AuthError -         Error: Amplify has not been configured correctly.         The configuration object is missing required auth properties.         Did you run `amplify push` after adding auth via `amplify add auth`?        See https://aws-amplify.github.io/docs/js/authentication#amplify-project-setup for    more information

Please let me know why exactly the above code is showing error when i run in iOS.


Viewing all articles
Browse latest Browse all 16750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>