【问题标题】:No User Pool when try to request cognito尝试请求 cognito 时没有用户池
【发布时间】:2019-06-18 09:06:00
【问题描述】:

我使用了amplify add auth,它工作正常,然后amplify push。 React 网站运行没有问题。但是当我尝试注册或登录时,我收到错误[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。 但是 aws_user_pools_id 与 aws 控制台中的 id 相同。 有人知道问题可能是什么吗? 谢谢;)

那是我的 App.js 没有魔法......

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);

【问题讨论】:

    标签: reactjs amazon-cognito aws-amplify


    【解决方案1】:

    问题是,您还必须添加配置方法:

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

    【讨论】:

      【解决方案2】:

      我在使用 aws 时遇到了类似的问题,为了解决这个问题,我简单地创建了一个新的用户池,之后我就可以登录并注册了。

      【讨论】:

      • 您是如何将新池与项目连接起来的?当我将新的 pool_id 粘贴到我的 react 项目中时,没有任何变化,我仍然收到错误。
      • 我可以检查你的代码,因为我无法挖掘这样的问题吗?
      • 你指的是哪一部分?我以与官方教程中相同的方式进行操作:aws-amplify.github.io/docs/js/react
      • 您能否从 aws export 中检索 aws 池配置?控制它并检查你是否得到它。
      • 我刚刚再次初始化 Amplify 并添加 auth。有一个新用户池,我的 aws-exports 中的 id 是相同的。可能是因为我使用的是export default withAuthenticator(App);
      【解决方案3】:

      我必须执行以下操作,并且成功了。

      amplify push
      amplify publish
      

      在那之后,No userPool 错误消失了,我收到了一个确认码,在电子邮件中收到了它,然后用它来确认我的帐户。然后我就可以登录了。

      【讨论】:

        【解决方案4】:

        为该地区增加价值为我解决了这个错误。 默认值:区域:'' 新:区域:'us-east-1'

        【讨论】:

          猜你喜欢
          • 2018-02-11
          • 2018-11-12
          • 2018-01-21
          • 2023-03-09
          • 2016-12-18
          • 1970-01-01
          • 2020-04-21
          • 2021-07-25
          • 2019-11-03
          相关资源
          最近更新 更多