“无用户池” Cognito错误身份验证React应用程序

时间:2019-07-10 19:23:04

标签: reactjs amazon-web-services aws-amplify

如果我要登录或注册帐户,则会收到错误消息No Userpool

我构建了一个AwsService来设置配置并调用AwsFunction

配置

const devConfig = {
  Auth: {
    aws_appsync_graphqlEndpoint: 'https://someHash.appsync-api.eu-central-1.amazonaws.com/graphql',
    aws_appsync_region: 'eu-central-1',
    aws_appsync_authenticationType: 'AMAZON_COGNITO_USER_POOLS',
    aws_appsync_apiKey: 'null',
  },
}

首先,我触发AwsService.init,它使用Amplify.configure(config)

设置配置

毕竟,我尝试连接以从Auth.signUp呼叫aws-amplify

AwsService.js

import Amplify, { Auth } from 'aws-amplify'

class AwsService {
  signUp ({ fullName, email, password }) {
    Auth.signUp({
      name: fullName,
      email,
      password,
    })
      .then(user => console.log('user', user))
      .catch(err => console.log('err', err))
  }
...

作为响应,我在错误函数中收到No Userpool错误。

1 个答案:

答案 0 :(得分:0)

将显示错误,因为从AWS生成的配置为false,并且需要其他参数。

正确的配置参数是:

const devConfig = {
  Auth: {
    identityPoolId: 'eu-central-1:somehash', 
    region: 'eu-central-1', 
    userPoolId: 'eu-central-1_Hash',
    userPoolWebClientId: 'otherHash', 
  },
}