【问题标题】:How to create user in amazon-cognito using boto3 in python如何在 python 中使用 boto3 在 amazon-cognito 中创建用户
【发布时间】:2019-11-03 23:16:54
【问题描述】:

我正在尝试使用 python3.x 和 boto3 创建用户,但最终遇到了一些问题

我尝试过使用“admin_create_user”,即使 id 对我不起作用

import boto3
aws_client = boto3.client('cognito-idp', 
    region_name = CONFIG["cognito"]["region"]
)
response = aws_client.admin_create_user(
    UserPoolId = CONFIG["cognito"]["pool_id"],
    Username = email, 
    UserAttributes = [
        {"Name": "first_name", "Value": first_name},
        {"Name": "last_name", "Value": last_name},
        { "Name": "email_verified", "Value": "true" }
    ],
    DesiredDeliveryMediums = ['EMAIL']
)

Error facing

【问题讨论】:

  • 错误说明了一切。您没有在任何地方传递访问密钥和秘密密钥,也没有在 awscli 中将其保存在您的机器上。

标签: python python-3.x boto3 amazon-cognito


【解决方案1】:
  • 我认为你没有通过配置。首先安装AWS CLI

pip install awscli --upgrade --user

  • 然后在终端中输入以下命令,

aws configure

  • 正确提供您的详细信息,
AWS Access Key ID [****************6GOW]: 
AWS Secret Access Key [****************BHOD]: 
Default region name [us-east-1]: 
Default output format [None]:

试试这个,您还可以在以下路径中查看您的凭据。

sudo cat ~/.aws/credentials

[default]
aws_access_key_id = ******7MVXLBPHW66GOW
aws_secret_access_key = wKtT*****UqN1sO/1Pfn+BCrvNst*****695BHOD
sudo cat ~/.aws/config

[default]
region = us-east-1

或者您可以通过aws configure list 命令在一个地方查看所有这些,

【讨论】:

    猜你喜欢
    • 2016-03-15
    • 2017-10-29
    • 2020-09-27
    • 2022-11-04
    • 2018-07-27
    • 2020-02-02
    • 2014-11-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多