【问题标题】:AWS-Amplify: Unauthenticated access is not supported for this identity poolAWS-Amplify:此身份池不支持未经身份验证的访问
【发布时间】:2019-02-09 13:34:25
【问题描述】:

我正在使用:https://github.com/aws-amplify/amplify-js

是否有任何工作示例如何使用经过身份验证的 AWS 访问?我正在使用这个:

Amplify.configure({
        Auth: {
            identityPoolId: configs.broker.identityPoolId,
            region: configs.broker.aws_pubsub_region,
            userPoolId: configs.broker.userPoolId,
            userPoolWebClientId: configs.broker.userPoolWebClientId,
        }
});

Amplify.addPluggable(new AWSIoTProvider(configs.broker));

Auth.signIn(configs.broker.username, configs.broker.password)
    .then(user => {                
        resolve({ code: 200, message: 'Authorized access to AWS is used' })
    })
    .catch(singInErr => resolve({ code: 500, message: singInErr.message }));

如果没问题(没问题):

    PubSub.publish(configs.broker.topic, JSON.stringify(data))
         .then(res => resolve({
              code: 200,
              message: 'OK'
         }))
         .catch(err => resolve({
              code: 500,
              message: err.toString()
         }));

但我不断得到:

[未处理的承诺拒绝:NotAuthorizedException:此身份池不支持未经身份验证的访问。]

【问题讨论】:

    标签: react-native aws-amplify cognito


    【解决方案1】:

    您是否使用amplify-cli 设置了身份验证?我对 graphql 和 cognito 有类似的问题。通过转到身份池设置并设置Unauthenticated roleAuthenticated role 解决了这个问题。我刚刚使用了通过放大 cli 创建的那些。

    我正在尝试从记忆中回忆这一点,因此可能缺少某些部分。但粗略的步骤是:

    1. 转到https://eu-west-1.console.aws.amazon.com/cognito/federated
    2. 从顶部栏中选择您所在的区域。
    3. 如果您有身份池,您应该会看到一个表格。在它上方有一个指向其设置的链接。点击那个。
    4. 在右上角,Support 下方有Edit Identity Pool。点击那个。
    5. 您应该会看到一个屏幕,其中包含两个选项 Unauthenticated roleAuthenticated role。单击选择框并选择适当的角色。如果您创建了放大堆栈,它应该有两个角色,其中包含单词 unauthdRoleauthRole 选择那些。

    它现在应该可以工作了。这是假设您有正确的身份池和用户池设置。

    【讨论】:

    • 你到底做了什么?您可以在分步手册中添加一些链接吗?
    猜你喜欢
    • 2017-07-01
    • 1970-01-01
    • 2017-05-31
    • 2019-03-24
    • 2017-06-14
    • 2016-06-24
    • 1970-01-01
    • 1970-01-01
    • 2016-10-09
    相关资源
    最近更新 更多