Amazon Cognito Error:尝试执行updateUserAttributes Cognito服务的错误(会员必须满足正则表达式模式:[A-Za-z0-9-_=]。]+))

时间:2022-12-25 21:14:47

I'm trying to do updateUserAttributes of Class: AWS.CognitoIdentityServiceProvider bearing in mind with Node js http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CognitoIdentityServiceProvider.html#updateUserAttributes-property

我在尝试做类的updateUserAttributes: AWS。CognitoIdentityServiceProvider记住节点js http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CognitoIdentityServiceProvider.html#updateUserAttributes-property

// Set credentials
AWS.config.region = 'us-east-1';
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
  IdentityPoolId: 'us-east-1:XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
});
let CognitoIdentityServiceProvider = AWS.CognitoIdentityServiceProvider();

// Make the call to obtain credentials
AWS.config.credentials.get(function() {
  // Credentials will be available when this function is called.
  var token = AWS.config.credentials.sessionToken;
  var params = {
    UserAttributes: [{
      Name: 'custom:XXXXXXXX',
      Value: 'XXXXXXXX'
    }],
    AccessToken: token
  };
  CognitoIdentityServiceProvider.updateUserAttributes(params, function(err, data) {
    if (err) {
      console.log(err, err.stack); // an error occurred
      return callback(false, err.stack);
    }
    console.log(data);
    callback(true, data);
  });
});

And the response is: { [InvalidParameterException: 1 validation error detected: Value at 'accessToken' failed to satisfy constraint: Member must satisfy regular expression pattern: [A-Za-z0-9-_=.]+]
message: '1 validation error detected: Value at \'accessToken\' failed to satisfy constraint: Member must satisfy regular expression pattern: [A-Za-z0-9-_=.]+',
code: 'InvalidParameterException',
time: Thu Jun 23 2016 09:50:15 GMT-0500 (COT),
requestId: 'cb98c60f-3951-11e6-a4c2-3d6c71f21f4c',
statusCode: 400,
retryable: false,
retryDelay: 36.788223031908274 }

响应为:{[InvalidParameterException: 1 validation error detection:值at 'accessToken'未能满足约束:成员必须满足正则表达式模式:[A-Za-z0-9-_=]。]+]消息:“检测到的1个验证错误:\'accessToken\'值未能满足约束:成员必须满足正则表达式模式:[A-Za-z0-9-_=。[]+',代码:‘InvalidParameterException’,time: Thu Jun 2016 09:50:15 GMT-0500 (COT), requestId:‘cb98c60f-3951-11e6-a4c2- 3d6c71f21f21f4c’,statusCode: 400, retryable: false, retryDelay:

I'm doing something wrong?

我做错了什么吗?

1 个解决方案

#1


3  

The AccessToken accepted by CognitoIdentityServiceProvider is not the session token from your AWS credentials. It is one of the tokens vended by the Cognito User Pools service (Identity Provider) when you authenticate a user using username and password.

CognitoIdentityServiceProvider接受的AccessToken不是AWS凭据中的会话令牌。当您使用用户名和密码对用户进行身份验证时,它是Cognito User Pools服务(Identity Provider)提供的令牌之一。

See this guide for instructions to use our Cognito User Pools JavaScript SDK.

有关使用Cognito用户池JavaScript SDK的说明,请参阅本指南。

#1


3  

The AccessToken accepted by CognitoIdentityServiceProvider is not the session token from your AWS credentials. It is one of the tokens vended by the Cognito User Pools service (Identity Provider) when you authenticate a user using username and password.

CognitoIdentityServiceProvider接受的AccessToken不是AWS凭据中的会话令牌。当您使用用户名和密码对用户进行身份验证时,它是Cognito User Pools服务(Identity Provider)提供的令牌之一。

See this guide for instructions to use our Cognito User Pools JavaScript SDK.

有关使用Cognito用户池JavaScript SDK的说明,请参阅本指南。