【问题标题】:AWS Amplify Auth is not configured correctlyAWS Amplify Auth 配置不正确
【发布时间】:2023-03-22 01:58:01
【问题描述】:

我在 AWS 上有一个 react-app,最近做了两个更改:实现了 Amplify Auth 并从另一个项目复制了 /src 和 /public。该项目开始正常,但登录失败。页面顶部显示:

在浏览器控制台日志中:

[ERROR] 04:07.792 AuthError - 
            Error: Amplify has not been configured correctly. 
            The configuration object is missing required auth properties. 
            Did you run `amplify push` after adding auth via `amplify add auth`?
            See https://aws-amplify.github.io/docs/js/authentication#amplify-project-setup for more information
        index.js:1
    e index.js:1
    _log ConsoleLogger.ts:91
    error ConsoleLogger.ts:142
    AuthError Errors.ts:34
    NoUserPoolError Errors.ts:39
    rejectNoUserPool Auth.ts:2188
    currentUserPoolUser Auth.ts:1194
    currentAuthenticatedUser Auth.ts:1360
    step 3.chunk.js:61574
    verb 3.chunk.js:61505
    fulfilled 3

如何解决。

我尝试通过删除并重新添加 Auth “amplify auth remove”、“amplify auth add”,然后是“amplify update api”和“amplify push”来修复它,但这没有任何区别。

在“C:\myproject\amplify\backend\auth”中,auth-bucket 的目录包含parameters.json,我觉得很好。

    {
    "identityPoolName": "myprojecte1066c9_identitypool_fe1066c9",
    "allowUnauthenticatedIdentities": false,
    "resourceNameTruncated": "myprojectfe1066c9",
    "userPoolName": "myprojectfe1066c9_userpool_fe1066c9",
    "autoVerifiedAttributes": [
        "email"
    ],
    "mfaConfiguration": "OFF",
    "mfaTypes": [
        "SMS Text Message"
    ],
    "smsAuthenticationMessage": "Your authentication code is {####}",
    "smsVerificationMessage": "Your verification code is {####}",
    "emailVerificationSubject": "Your verification code",
    "emailVerificationMessage": "Your verification code is {####}",
    "defaultPasswordPolicy": false,
    "passwordPolicyMinLength": 8,
    "passwordPolicyCharacters": [],
    "requiredAttributes": [
        "email"
    ],
    "userpoolClientGenerateSecret": false,
    "userpoolClientRefreshTokenValidity": 30,
    "userpoolClientWriteAttributes": [
        "email"
    ],
    "userpoolClientReadAttributes": [
        "email"
    ],
    "userpoolClientLambdaRole": "myprojectfe1066c9_userpoolclient_lambda_role",
    "userpoolClientSetAttributes": false,
    "sharedId": "fe1066c9",
    "resourceName": "myprojectfe1066c9",
    "authSelections": "identityPoolAndUserPool",
    "authRoleArn": {
        "Fn::GetAtt": [
            "AuthRole",
            "Arn"
        ]
    },
    "unauthRoleArn": {
        "Fn::GetAtt": [
            "UnauthRole",
            "Arn"
        ]
    },
    "useDefault": "default",
    "userPoolGroupList": [],
    "serviceName": "Cognito",
    "dependsOn": []
}

有什么想法吗?

【问题讨论】:

    标签: amazon-web-services authentication amplify


    【解决方案1】:

    我也遇到过同样的问题,当你没有在 index.js 中配置 amplify 时会发生这种情况

    您需要确保在您的应用尝试使用 Amplify 之前调用以下代码。

    import awsExports from './aws-exports';
    Amplify.configure(awsExports);
    

    【讨论】:

      猜你喜欢
      • 2020-12-16
      • 2021-01-30
      • 2021-11-20
      • 2020-01-08
      • 2020-11-18
      • 2019-12-25
      • 2022-11-11
      • 2019-12-14
      • 2020-12-15
      相关资源
      最近更新 更多