【问题标题】:How can i use aws amplify cognito in react native?我如何在原生反应中使用 aws amplify cognito?
【发布时间】:2020-06-20 02:24:54
【问题描述】:

我正在尝试将 AWS 身份验证功能添加到应用程序。我已将配置添加到已经具有 graphql 和 pubsub 配置的文件中,我正在调用 App.js 中的Amplify.configure({ ...config.GraphQL, Auth: config.Auth })。 在尝试使用注册时,我在日志[NoUserPoolError: Authentication Error] 中收到以下错误。

验证码

import { Auth } from 'aws-amplify';
...

        Auth.signUp({
            username: email,
            password,
            attributes: {
                email // optional
                // other custom attributes
            },
            validationData: [] //optional
        })
            .then(data => console.log(data))
            .catch(err => console.log('Error:Auth.signUp ', err));

我的配置如下

    Auth: {
        IdentityPoolId: 'xxxxxxxx',
        identityPoolId: 'xxxxxxxx',
        Region: 'xxxxxxxx',
        region: 'xxxxxxxx',
        RoleArn: 'xxxxxxxx',
        UserPoolId: 'xxxxxxxx',
        ClientId: 'xxxxxxxx'
    },
    GraphQL:{
             //config for graphql
    }

在应用程序中,我得到如下红屏。

我还没试过amplify push

【问题讨论】:

    标签: react-native amazon-cognito aws-amplify


    【解决方案1】:

    所以我发现了这个问题,所以回答我自己的问题。问题出在配置中。应该是这样的。

        Auth: {
            IdentityPoolId: 'xxxxxxxx',
            identityPoolId: 'xxxxxxxx',
            Region: 'xxxxxxxx',
            region: 'xxxxxxxx',
            RoleArn: 'xxxxxxxx',
            userPoolId: 'xxxxxxxx', // this was previously UserPoolId
            userPoolWebClientId: 'xxxxxxxx', // this was previously ClientId
            authenticationFlowType:'xxxxxxx'
        },
        GraphQL:{
                 //config for graphql
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-04
      • 2021-07-31
      • 2022-01-25
      • 2019-04-28
      • 2021-03-01
      • 2021-09-28
      • 2020-01-01
      • 2022-12-10
      相关资源
      最近更新 更多