首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >未正确配置AWS Amplify Auth

未正确配置AWS Amplify Auth
EN

Stack Overflow用户
提问于 2021-03-08 16:41:21
回答 1查看 662关注 0票数 1

我在亚马逊网络服务上有一个react-app,最近做了两个更改:实现了Amplify Auth,并从另一个项目复制了/src和/public,覆盖了我当前的项目。项目开始时运行良好,但登录失败。页面顶部显示:

在浏览器控制台日志中:

代码语言:javascript
复制
[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,这在我看来没问题。

代码语言:javascript
复制
    {
    "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": []
}

有什么想法吗?

EN

回答 1

Stack Overflow用户

发布于 2021-03-18 21:55:24

我遇到过完全相同的问题,当您没有在index.js中配置amplify时,就会发生这种情况

在你的应用程序尝试使用Amplify之前,你需要确保调用下面的代码。

代码语言:javascript
复制
import awsExports from './aws-exports';
Amplify.configure(awsExports);
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66526625

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档