[英]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.