您好我在python中制作HTTP POST请求脚本时遇到了问题。这是关于我必须实现的目标的描述,但我不知道从哪里开始。描述是:
描述
1,构造一个如下所示的JSON字符串:
{
"github_url": "https://gist.github.com/YOUR_ACCOUNT/GIST_ID",
"contact_email": "EMAIL"
}
然后,对包含JSON字符串作为正文部分的URL http://WEBSITE发出HTTP POST请求。
Content-Type: of the request must be "application/json".
The URL is protected by HTTP Basic Authentication, which is explained on Chapter 2 of RFC2617, so you have to provide an Authorization: header field in your POST request
For the "userid" of HTTP Basic Authentication, use the same email address you put in the JSON string.
对于“密码”,提供符合RFC6238 TOTP的10位基于时间的一次性密码。 您必须阅读RFC6238(以及勘误表!)并自行获取正确的一次性密码。 TOTP的“时间步长X”是30秒。 “T0”为0。
使用HMAC-SHA-512
代替默认HMAC-SHA-1
。
令牌共享密钥是userid,后跟ASCII字符串值“CATE399”(不包括双引号)。
1. For example, if the userid is "some@example.com", the token shared secret is "some@example.comCATE399".
2. For example, if the userid is "some@example.com", the token shared secret is "some@example.comCATE399"
如果您的POST请求成功,服务器将返回HTTP状态代码200。
任何人都可以为我制作一个http post请求脚本吗?
答案 0 :(得分:0)
TOTP有很多python库,下面是一个例子https://github.com/pyotp/pyotp
在这种情况下,您的代码将如下所示:
import pyotp
totp = pyotp.TOTP(“CATE399”)
password = totp.now()