Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
AWS Cognito javascript出现奇怪的一般错误-响应加密?_Javascript_Json_Amazon Web Services_Encryption - Fatal编程技术网

AWS Cognito javascript出现奇怪的一般错误-响应加密?

AWS Cognito javascript出现奇怪的一般错误-响应加密?,javascript,json,amazon-web-services,encryption,Javascript,Json,Amazon Web Services,Encryption,我正试图通过javascript将Cognito实现到我的web应用程序中。我打算允许通过facebook和google登录,但现在我只是尝试设置用户注册和通过cognito登录。我按照这里的指示: 这就是我的注册代码: AWS.config.region = 'us-east-1'; // Region AWSCognito.config.region = 'us-east-1'; AWSCognito.config.credentials = new AWS.CognitoIdentityC

我正试图通过javascript将Cognito实现到我的web应用程序中。我打算允许通过facebook和google登录,但现在我只是尝试设置用户注册和通过cognito登录。我按照这里的指示:

这就是我的注册代码:

AWS.config.region = 'us-east-1'; // Region
AWSCognito.config.region = 'us-east-1';
AWSCognito.config.credentials = new AWS.CognitoIdentityCredentials({
    IdentityPoolId: 'us-east-xxx' // your identity pool id here
});

var userPool = new AWSCognito.CognitoIdentityServiceProvider.CognitoUserPool({
    UserPoolId: 'us-east-xxx',
    ClientId: 'xxx',
    Paranoia: 7
});
console.log(userPool, 'userPool')

var attributeList = [
    new AWSCognito.CognitoIdentityServiceProvider.CognitoUserAttribute({
        Name: 'email',
        Value: email
    }),
    new AWSCognito.CognitoIdentityServiceProvider.CognitoUserAttribute({
        Name: 'preferred_username',
        Value: username
    }),
    new AWSCognito.CognitoIdentityServiceProvider.CognitoUserAttribute({
        Name: 'phone_number',
        Value: phone
    }),
    new AWSCognito.CognitoIdentityServiceProvider.CognitoUserAttribute({
        Name: 'given_name',
        Value: firstname
    }),
    new AWSCognito.CognitoIdentityServiceProvider.CognitoUserAttribute({
        Name: 'family_name',
        Value: lastname
    })
];

    userPool.signUp(this.state.signup.username, this.state.signup.password, attributeList, null, function(err, result){
        if (err) {
            console.error(err);
            return;
        }
        cognitoUser = result.user;
        console.log('user name is ' + cognitoUser.getUsername());
    });

代码实际上运行良好。用户是在我的用户池中创建的(我可以在我的Cognito管理控制台中看到该用户。但是当我提交运行此代码的表单时,我在javascript控制台中得到一个错误,只显示“error”。当我检查API响应时,它显示“SyntaxError:JSON.parse:JSON数据第1行第1列的意外字符”。然后我检查原始响应,它只是一长串看似随机的字符。我不知道响应是加密的还是base64编码的,或者…我做错了什么?

如果你认为它可能是base64,为什么不试着解码它呢?轻拍他的鼻子两次…谢谢,没问题。希望它能解决:)好吧,是和否。它肯定是base64编码的,但我不明白为什么。我在文档中找不到任何关于base64编码响应的地方。我没有办法去理解它。这很令人沮丧。比如,在那个注册方法中。。。回调函数从未被调用,因为它阻塞了base64编码的响应。如果你认为它可能是base64,为什么不尝试解码它?轻敲他的鼻子两次。。。谢谢,没问题。希望解决了:)好吧,是的,不是。它肯定是base64编码的,但我不明白为什么。我在文档中找不到任何关于base64编码响应的地方。我没有办法去理解它。这很令人沮丧。比如,在那个注册方法中。。。回调函数永远不会被调用,因为它会阻塞base64编码的响应