Closed SwhiteMHC closed 11 months ago
Hi @SwhiteMHC thank you for opening this issue. Out of curiousity are you seeing an issue if you use the aws-amplify/auth
apis directly?
import { signIn } from 'aws-amplify/auth'; // <== use this directly
import React from 'react';
import {View,Button} from 'react-native';
function App() {
const handleSignIn = async () => {
try {
const result = await signIn({
username,
password
})
} catch (error) {
console.log(error)
}
}
return (
<View style={styles.container}>
<Button onPress={handleSignIn} title="SignIn" />
</View>
);
}
The exception "Auth UserPool not configured." is thrown when Amplify.getConfig().Auth?.Cognito
doesn't return a valid configuration.
Looking at your code, you were import amplify config object from amplifyconfiguration.json
file, but you were not using this object but did manual configuration, any specific reason for doing so?
You have the following code in the index.js
// You can get the current config object
const currentConfig = Amplify.getConfig();
Can you use console.log
to print the currentConfig
variable to inspect the object?
Also can you try the follow without the manual configuration see if there is a difference?
import amplifyconfig from './src/amplifyconfiguration.json';
Amplify.configure(amplifyconfig);
@HuiSF My apologies, I had imported and used the configuration file initially, encountered the error, and attempted to pass a custom configuration. I get the same error when switching back. When I log the config, it is an empty object {}.
I moved the code outside of index.js and into app.js, and it is now working as expected.
index.js
// Put your code below this line - INDEX.JS
/**
* @format
*/
// React
import 'react-native-url-polyfill/auto';
import 'react-native-get-random-values';
import {AppRegistry} from 'react-native';
// Components
import App from './App';
import {name as appName} from './app.json';
AppRegistry.registerComponent(appName, () => App);
import React from 'react';
import MapView, {Marker} from 'react-native-maps';
import {StyleSheet, View} from 'react-native';
// AWS
import {Authenticator} from '@aws-amplify/ui-react-native';
import * as amplifyconfig from './src/amplifyconfiguration.json';
import {Amplify} from 'aws-amplify';
Amplify.configure(amplifyconfig);
function App() {
return (
<Authenticator.Provider>
<Authenticator>
<View style={styles.container}>
<MapView
style={styles.map}
region={{
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
}}>
<Marker
key="1"
title="1"
description="1"
coordinate={{
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
}}
/>
</MapView>
</View>
</Authenticator>
</Authenticator.Provider>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
map: {
width: '100%',
height: '100%',
},
});
export default App;
Unfortunately now my MapView is not working... Another package another problem. I think you can close this.
Thanks for following up @SwhiteMHC. Closing as it was a non-issue.
Before opening, please confirm:
JavaScript Framework
React Native
Amplify APIs
Authentication
Amplify Categories
auth
Environment information
Describe the bug
Following these instructions: https://docs.amplify.aws/react-native/build-a-backend/auth/set-up-auth/, and these instructions, https://ui.docs.amplify.aws/react-native/connected-components/authenticator/configuration. I am unable to get Auth working correctly. Each time I attempt to sign in, I get Auth UserPool not configured.
Expected behavior
I am able to log in using password and username.
Reproduction steps
Standard instructions for v6 AWS-Amplify for React Native.
Code Snippet
Log output
aws-exports.js
Manual configuration
Additional configuration
Mobile Device
Android S< A14
Mobile Operating System
Android
Mobile Browser
N/A
Mobile Browser Version
No response
Additional information and screenshots