【问题标题】:Reconnecting awsmobile with cognito auth: Get no userPool error使用 cognito auth 重新连接 awsmobile:未获取 userPool 错误
【发布时间】:2018-04-26 07:17:59
【问题描述】:

我将一个正常运行的项目移到了一台新机器上,并按照建议的步骤通过将 awsmobile 项目链接到现有的移动集线器项目来重新初始化它。

除了登录导致“无用户池”错误消息外,一切似乎都按预期进行。

我查看了其他相关的溢出问题,但它们似乎并不适用。

  • 似乎没有第二个 aws-amplify 安装
  • 我在使用前配置放大器
  • 所有后端设置均由 awsmobile 客户端自动生成
  • 移动中心页面显示已设置用户登录。
  • aws_user_pools 表示已启用,相关设置显示在配置中

我通过以下命令连接到现有的移动集线器项目:

awsmobile init <mobile hub project GUID>

以“已成功链接 AWS Mobile Hub 项目:”结尾。

amplify 正在加载的配置文件如下(它也是由 awsmobile init 自动生成的):

const awsmobile = {
    'aws_app_analytics': 'enable',
    'aws_auth_facebook': 'enable',
    'aws_cognito_identity_pool_id': '<value here removed>',
    'aws_cognito_region': '<value here removed>',
    'aws_content_delivery': 'enable',
    'aws_content_delivery_bucket': '<value here removed>',
    'aws_content_delivery_bucket_region': '<value here removed>',
    'aws_content_delivery_cloudfront': 'enable',
    'aws_content_delivery_cloudfront_domain': '<value here removed>',
    'aws_facebook_app_id': '<value here removed>',
    'aws_facebook_app_permissions': 'public_profile',
    'aws_mobile_analytics_app_id': '<value here removed>',
    'aws_mobile_analytics_app_region': '<value here removed>',
    'aws_project_id': '<value here removed>',
    'aws_project_name': '<value here removed>',
    'aws_project_region': '<value here removed>',
    'aws_resource_name_prefix': '<value here removed>',
    'aws_sign_in_enabled': 'enable',
    'aws_user_pools': 'enable',
    'aws_user_pools_id': '<value here removed>',
    'aws_user_pools_web_client_id': '<value here removed>',
}

有什么建议吗?我可以调查的事情?

(以前的机器也死了,AWS 建议您不要将配置对象签入源代码管理。所以我无法将 delta 的当前配置文件与以前的机器进行比较。)

谢谢!

在校对时修正格式错误和语法清晰度

【问题讨论】:

    标签: react-native aws-mobilehub aws-amplify aws-userpools


    【解决方案1】:

    在逐步完成 withAuthenticator HOC 及其在 aws-amplify/Auth/Auth.js 中对 AuthClass 对象的使用后,发现问题实际上与堆栈溢出问题有关:

    AWS Amplify: How to setup { withConnector } component?

    该解决方案提到在 aws-amplify-react 下的 node_modules 中寻找重复的 aws-amplify 安装。我的特定实现是 react native,所以我查看了 aws-amplify-react-native,果然,它有一个带有 aws-amplify 的 node_modules。删除使解决方案起作用。

    这是因为在 App.js 文件中配置了放大。但是 withAuthenticator HOC 从 aws-amplify-react-native 加载,它首先使用从未配置过的自己的 node_modules 中的 Auth 对象。

    【讨论】:

      猜你喜欢
      • 2019-09-09
      • 2020-07-03
      • 1970-01-01
      • 2020-03-19
      • 2021-07-07
      • 2015-02-13
      • 2019-06-19
      • 1970-01-01
      • 2014-03-14
      相关资源
      最近更新 更多