使用 cognito auth 重新连接 awsmobile:没有 userPool 错误

Reconnecting awsmobile with cognito auth: Get no userPool error

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

除了登录导致出现 "No userPool" 错误消息外,一切似乎都按预期进行。

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

我通过以下命令连接到现有的移动中心项目:

awsmobile init <mobile hub project GUID>

以 "Successfully linked AWS Mobile Hub project: " 结尾。

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 的当前配置文件与之前的机器进行比较。)

谢谢!

编辑以修复格式错误和校对时的一些语法清晰度

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

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

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