No User Pool when try to request cognito

2019-08-30 04:28发布

问题:

I used amplify add auth that works fine and then amplify push. The React website is running without a problem. But when I try to register or login, I get the error [ERROR] AuthClass - Cannot get the current user because the user pool is missing. Please make sure the Auth module is configured with a valid Cognito User Pool ID. But the aws_user_pools_id is the same like in the id in the aws console. Have someone an idea what the problem could be? thanks ;)

Thats my App.js with no magic...

import React, { Component } from 'react';
import './App.css';
import HomeScreen from './screens/HomeScreen';
import { withAuthenticator } from 'aws-amplify-react';

class App extends Component {
  render() {
    return (
      <div className="App">
        <HomeScreen />
      </div>
    );
  }
}

export default withAuthenticator(App);

回答1:

I had faced a similar issue with aws and to overcome I simply created a new user pool after which I was able to log in and register.



回答2:

The Problem was, that you have to add the configure method as well:

import Amplify from 'aws-amplify';
import aws_exports from './aws-exports';
import { withAuthenticator } from 'aws-amplify-react';
Amplify.configure(aws_exports);