简体   繁体   English

从 aws cli 或 nodeJS 创建认知池 ID 出错,参数有什么问题?

[英]Create cognito pool id from aws cli or nodeJS got error, what's wrong with the params?

I created nodeJS scripts to setup my AWS Cognito Pool ID using class "CreateIdentityPool":我创建了 nodeJS 脚本来使用类“CreateIdentityPool”设置我的AWS Cognito Pool ID

var cognitoidentity = new AWS.CognitoIdentity();
var params = {
    "IdentityPoolName": "samplePool",
    "AllowUnauthenticatedIdentities": true,
    "CognitoIdentityProviders": [
      {
        "ClientId": "xxxxxxxxxxx-qea4ebra0gipd0krefi37v8f48svrp8e.apps.googleusercontent.com", /* google client ID */
        "ProviderName": "accounts.google.com"
      }
    ],
    "DeveloperProviderName": "mypool"
};
cognitoidentity.createIdentityPool(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

but it got an errors below :但它有以下错误:

{ [ValidationException: 1 validation error detected: Value 'xxxxxxxxxxx-qea4ebra0gipd0krefi37v8f48svrp8e.apps.googleusercontent.com' at 'cognitoIdentityProviders.1.member.clientId' failed to satisfy constraint: Member must satisfy regular expression pattern: [\\w_]+] message: '1 validation error detected: Value \\'xxxxxxxxxxx-qea4ebra0gipd0krefi37v8f48svrp8e.apps.googleusercontent.com\\' at \\'cognitoIdentityProviders.1.member.clientId\\' failed to satisfy constraint: Member must satisfy regular expression pattern: [\\w_]+', code: 'ValidationException', time: Tue Jan 31 2017 21:11:48 GMT+1100 (AEDT), requestId: 'ad2b3366-e79d-11e6-b2e7-578f32ddcea5', statusCode: 400, { [ValidationException: 1 个验证错误检测到:值 'xxxxxxxxxxx-qea4ebra0gipd0krefi37v8f48svrp8e.apps.googleusercontent.com' at 'cognitoIdentityProviders.1.member.clientId' 未能满足约束:成员必须满足正则表达式模式:[\\w_]+] 消息:'检测到 1 个验证错误:值 \\'xxxxxxxxxxx-qea4ebra0gipd0krefi37v8f48svrp8e.apps.googleusercontent.com\\' at \\'cognitoIdentityProviders.1.member.clientId\\' 未能满足约束:成员必须满足正则表达式模式:[\\w_]+ ', 代码: 'ValidationException', 时间: Tue Jan 31 2017 21:11:48 GMT+1100 (AEDT), requestId: 'ad2b3366-e79d-11e6-b2e7-578f32ddcea5', statusCode: 400,
retryable: false, retryDelay: 45.71310137398541 }可重试:假,重试延迟:45.71310137398541 }

Second way, I tried create identity pool id first without CognitoIdentityProviders and then run update using class "UpdateIdentityPool" to add CognitoIdentityProviders (unlock the authentication providers).第二种方式,我尝试先在没有CognitoIdentityProviders 的情况下创建身份池 ID,然后使用类“UpdateIdentityPool”运行更新以添加 CognitoIdentityProviders(解锁身份验证提供程序)。 But, it was same issue above.但是,上面是同样的问题。

Third way, I tried create identity pool id with argumen --cognito-identity-providers from aws cli and still got same issue :第三种方式,我尝试使用aws cli 的参数--cognito-identity-providers创建身份池 ID,但仍然遇到相同的问题:

An error occurred (ValidationException) when calling the UpdateIdentityPool operation: 1 validation error detected: Value 'xxxxxxxxxxx-qea4ebra0gipd0krefi37v8f48svrp8e' at 'cognitoIdentityProviders.1.member.clientId' failed to satisfy constraint: Member must satisfy regular expression pattern: [\\w_]+调用 UpdateIdentityPool 操作时发生错误 (ValidationException):检测到 1 个验证错误:值 'xxxxxxxxxxx-qea4ebra0gipd0krefi37v8f48svrp8e' at 'cognitoIdentityProviders.1.member.clientId' 未能满足约束:成员必须满足正则表达式模式:[\\w_]+

Fourth way, I tried create identity pool id without --cognito-identity-providers from aws cli and then update it from aws cli (add --cognito-identity-providers).第四种方式,我尝试从 aws cli 创建没有 --cognito-identity-providers 的身份池 ID,然后从 aws cli 更新它(添加 --cognito-identity-providers)。 it was still same issue.这仍然是同样的问题。

Very frustated with this issue, I have to set it from nodeJS.对这个问题非常沮丧,我必须从 nodeJS 设置它。 So, please don't give suggestion to unlock auth providers from AWS Console.因此,请不要建议从 AWS 控制台解锁身份验证提供程序。 There is very poor references for this issue.这个问题的参考资料很差。 Really appreciate if you can link me to the solved references.如果您能将我链接到已解决的参考文献,真的很感激。

Thank you谢谢

You are using CognitoIdentityProviders but that is for AWS Cognito User pool.您正在使用CognitoIdentityProviders但这是用于 AWS Cognito 用户池。 You need to set the SupportedLoginProviders for it to work.您需要设置SupportedLoginProviders才能使其工作。 Like this:像这样:

var params = {
    "IdentityPoolName": "samplePool",
    "AllowUnauthenticatedIdentities": true,
    "SupportedLoginProviders": {
        "accounts.google.com": "xxxxxxxxxxx-qea4ebra0gipd0krefi37v8f48svrp8e.apps.googleusercontent.com",
     }
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 NodeJS(服务器端)从另一个账户访问 AWS Cognito 池 - Access AWS Cognito pool from another account using NodeJS( server side) Nodejs SDK:从 aws cli 添加 s3 存储桶事件通知得到 InvalidArgument:无法验证以下目标配置 - Nodejs SDK: adding s3 bucket eventnotification from aws cli got InvalidArgument: Unable to validate the following destination configurations Aws cognito 通过管理员 nodejs 创建用户 - Aws cognito create user by admin nodejs AWS - 使用nodejs的Cognito Identity - 如何处理令牌 - AWS - Cognito Identity with nodejs - What to do with tokens function 在从 aws 中的 s3 读取文件后将数据传递给 aws cognito 时退出 lambda 在 nodejs 中 - function exits when passing data to aws cognito after reading file from s3 in aws lambda in nodejs 您能否以编程方式创建 AWS Cognito 应用程序客户端? (节点) - Can you create AWS Cognito App Client Programmatically? (nodejs) Function 在 nodejs 中未定义错误。 我的代码有什么问题? - Function is not defined error in nodejs. What's wrong with my code? NodeJS中的AWS Lambda错误:“错误的参数” - AWS Lambda in NodeJS error: “Wrong arguments” 可以将用户从我的mongodb数据库迁移到AWS Cognito用户池吗? - Can users be migrated from my mongodb database to aws cognito user pool? nodeJS / Express:此RSVP承诺有什么问题? - nodeJS / Express: what's wrong with this RSVP promise?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM