当在 AWS Cognito cli 中使用 UserPool 中的 createUser 命令创建用户时,可能会遇到 UserAttributes 中包含特殊字符的情况。在这种情况下,需要对 UserAttributes 中的特殊字符进行转义。
以下是在 AWS Cognito cli 中转义 UserAttributes 中特殊字符的示例代码:
aws cognito-idp admin-create-user
--user-pool-id YOUR_USER_POOL_ID
--username USERNAME
--user-attributes Name='given_name',Value='john\ doe' Name='email',Value='johndoe@example.com'
aws cognito-idp admin-create-user
--user-pool-id YOUR_USER_POOL_ID
--username USERNAME
--user-attributes Name='given_name',Value='john-doe' Name='email',Value='johndoe@example.com' Name='custom:attr',Value='!@#%^&*()_-+=`~'
请注意,在使用这些命令时,需要将 YOUR_USER_POOL_ID 和用户名 USERNAME 替换为实际的值。