New to AWS, I'm trying to connect my registration and login form to AWS.
What I expected:
- Create a user in my userpool with signUp
- Log in to my apps with signIn
What is happening:
Error: Amplify has not been configured correctly
What I did:
- Create my UserPool on AWS
- Create an IAM user on AWS
Amplify ConfigureAmplify InitAmplify import authAmplify push- Add signUp component
async function signUp() {
try {
const { user } = await Auth.signUp({
username: email,
password,
attributes: {
'custom:code_postal': codePostal, // custom attribute, not standard
'custom:ville': ville,
'custom:pays': Pays,
address: adresse,
family_name: nom,
given_name: prenom,
'custom:marque': Marque,
'custom:modele': modele,
'custom:version': Version,
'custom:puissance_batterie': PuissanceBat,
},
autoSignIn: { // optional - enables auto sign in after user is confirmed
enabled: true,
}
});
console.log(user);
history.push("../tab/tab1");
} catch (error) {
console.log('error signing up:', error);
}
}
- Add a signIn component
async function signIn() {
try {
const user = await Auth.signIn(email, password);
} catch (error) {
console.log('error signing in', error);
}
}
Add the aws-exports.d.ts file (aws-exports.js was not found in my code)
declare const awsmobile: Record<string, any> export default awsmobile;
Ionic cap sync android
Ionic cap open
- I launch the app and the following error message appears:
File: https://localhost/assets/index-75803d82.js - Line 222 - Msg: [ERROR] 47:44.22 AuthError - Error: Amplify has not been configured correctly. The configuration object is missing required auth properties. This error is typically caused by one of the following scenarios:
1. Did you run amplify pushafter adding auth viaamplify add auth`? See https://aws-amplify.github.io/docs/js/authentication#amplify-project-setup
for more information 2. This could also be caused by multiple conflicting versions of amplify packages, see (https://docs.amplify.aws/lib/troubleshooting/upgrading/q/platform/js)
for help upgrading Amplify packages.
What I tried:
- Create another UserPool with amplify add auth with the default config
I managed to register someone It worked once, but then I got the same error
I tried also this code, which make login work but not with my own code, I didn't try register:
import { Amplify } from 'aws-amplify'; import awsConfig from './aws-exports';
Amplify.configure(awsConfig);
setupIonicReact();
const App: React.FC = () => ( <IonApp> <IonReactRouter> <Menu /> <IonTabs> <IonRouterOutlet id='main'> <Route exact path="/"> <Redirect to="/pages/Welcome/Welcome" /> </Route> <Route path="/tab1" component={Tab1} /> <Route path="/tab2" component={Tab2} /> <Route path="/tab3" component={Tab3} /> </IonRouterOutlet> <IonTabBar className='ion-tab-bar' slot="bottom"> <IonTabButton tab="Tab1" href="/Tab1"> <IonIcon aria-hidden="true" icon={home} /> <IonLabel>Home</IonLabel> </IonTabButton> <IonTabButton tab="Tab2" href="/Tab2"> <IonIcon aria-hidden="true" icon={speedometer} /> <IonLabel>Compteurs</IonLabel> </IonTabButton> <IonTabButton tab="Tab3" href="/Tab3"> <IonIcon aria-hidden="true" icon={navigateOutline} /> <IonLabel>Trouver ma borne</IonLabel> </IonTabButton> </IonTabBar> </IonTabs>
{/* Routes pour les autres pages */}
<Switch>
<Route path="/pages/Contact/Contact" component={Contact} />
<Route path="/pages/FAQ/FAQ" component={FAQ} />
<Route path="/pages/AboutUs/AboutUs" component={AboutUs} />
<Route path="/pages/AccountPage/AccountPage" component={AccountPage} />
<Route path="/pages/Welcome/welcome" component={WelcomePage} />
</Switch>
</IonReactRouter>
);
export default withAuthenticator(App);
If I haven't been clear on some points, please let me know. Thank you in advance for your clarification.