47 lines
1.7 KiB
Python
47 lines
1.7 KiB
Python
import requests
|
||
import json
|
||
|
||
# API接口地址
|
||
API_URL = "http://localhost:5000/api/verification-code"
|
||
|
||
# 凭据信息
|
||
credentials = {
|
||
"email": "eedbbfdd186@outlook.com",
|
||
"client_id": "9e5f94bc-e8a4-4e73-b8be-63364c29d753",
|
||
"refresh_token": "M.C544_BL2.0.U.-CmrNXHVufVZdj1*CaDuSw4WSQYVfF7ILMi4XYHeVQ!YJm56uJO5HPG9I2bOJIRrS3c5FgP9sDKB*HjA3O6wVY4Cr7hzNGWjujT*xZ5k4gOjRDVXx9ocaY1bf5J2HZgAoBJYjFq76*3h2xddMEGqp7iFjYDo3B9rcfRGh!G6rJ38vkWBSGw!7hcj21IWdZD!eIZqCx1o2tDrzeH*fRnuf*DoTQEFCDnFpCoulmQHDUBEFiBT8H*TzupejEgWTmXewN9tpcQwFituIbGScsDWdRuB5pcF63p7jazZdeZ8Bpa7pQb5Fc4mYUSwQS4Qx9CNNMYnwYuhiAVEXPcoppWCA7WXF!bgOxa7IuZASnWMiC!jqUu77KnwrHWZD14SDrFfwBQ$$",
|
||
"sender": "no-reply@cursor.sh" # 指定发件人为cursor的验证邮件
|
||
}
|
||
|
||
headers = {
|
||
"Content-Type": "application/json"
|
||
}
|
||
|
||
try:
|
||
# 发送POST请求
|
||
response = requests.post(
|
||
API_URL,
|
||
headers=headers,
|
||
json=credentials
|
||
)
|
||
|
||
# 输出响应内容
|
||
print(f"状态码: {response.status_code}")
|
||
print("响应内容:")
|
||
print(json.dumps(response.json(), indent=2, ensure_ascii=False))
|
||
|
||
# 如果成功,提取验证码和新的refresh_token
|
||
if response.status_code == 200:
|
||
result = response.json()
|
||
|
||
# 打印验证码
|
||
if result.get("verification_code"):
|
||
print(f"\n提取的验证码: {result['verification_code']}")
|
||
else:
|
||
print("\n未能提取到验证码,请检查邮件内容。")
|
||
|
||
# 打印refresh_token
|
||
if "refresh_token" in result and result["refresh_token"] != credentials["refresh_token"]:
|
||
print(f"\n新的refresh_token: {result['refresh_token']}")
|
||
|
||
except requests.exceptions.RequestException as e:
|
||
print(f"请求失败: {e}") |