将nodejshttppost脚本转换为Python

将nodejshttppost脚本转换为Python,python,node.js,http-post,boto3,amazon-cognito,Python,Node.js,Http Post,Boto3,Amazon Cognito,我正在尝试将这个Node.JS脚本(这是一个单元测试)调用为Python等价物。它基本上生成一个AWS令牌,并使用它作为HTTP post请求发送一个.json文件。如何用Python重新编写它?我已经完成了令牌生成部分 以下是NodeJS脚本: describe('Send config file', () => { let token = ''; before(function beforetest(done) { this.timeout(10000); to

我正在尝试将这个Node.JS脚本(这是一个单元测试)调用为Python等价物。它基本上生成一个AWS令牌,并使用它作为HTTP post请求发送一个.json文件。如何用Python重新编写它?我已经完成了令牌生成部分

以下是NodeJS脚本:

describe('Send config file', () => {
  let token = '';
  before(function beforetest(done) {
    this.timeout(10000);
    tokengen(cognitoUser, authenticationDetails).then((result) => {
      token = result.getAccessToken().getJwtToken();
      done();
    }, (err) => {
      done(err);
    });
  });

  it('should send config json', function test(done) {
    this.timeout(10000);
    chai.request(app)
      .post(`${route}/sendjson`).set('accesstoken', token)
      .send(vcamconfig)
      .end((err, res) => {
        expect(res).to.have.status(200);
        expect(res.body).to.be.an('object');
        expect(res.body).to.have.property('msg');
        expect(res.body.msg).to.equal('Uploaded to S3');
        console.log(res.body);
        done();
      });
  });
});
这是我到目前为止试图生成AWS令牌的python脚本。我需要使用令牌发送一个文件作为POST请求

from warrant.aws_srp import AWSSRP
import boto3

username = "user3"
password = "user3"
client_id = "myclientID1234567890"
user_pool_id = "us-east-1_sdhjsasls"
region = "us-east-1"

client = boto3.client('cognito-idp', region_name=region)

aws = AWSSRP(username=username, password=password, pool_id=user_pool_id, client_id=client_id, client=client)
tokens = aws.authenticate_user()
print(tokens)

为什么不使用现有的节点代码呢?我不是一个节点爱好者,如果我以后想添加更多的功能,这对我来说会很困难。