如何通过https://api.steampowered.com/ISteamUserAuth/AuthenticateUser/v0001 api方法访问用户?
例如,我将从https://steamcommunity.com/login/getrsakey/获得蒸汽公钥数据,进行一些加密,然后将这些数据作为POST发送到指定的api。但是服务器每次都会返回'403禁忌‘。
我的代码示例:
from Crypto.Cipher import AES
from Crypto.Cipher.PKCS1_v1_5 import PKCS115_Cipher
from Crypto.PublicKey import RSA
from Crypto.Random import get_random_bytes
import hashlib
import json
import requests
steamid = '<MY_STEAMID64>'
steampass = '<MY_STEAM_PASSWORD>'
loginkey = hashlib.md5(bytes(steampass, 'utf-8')).hexdigest()
blob32 = get_random_bytes(32)
getrsa_url = 'https://steamcommunity.com/login/getrsakey/'
getrsa_data = {'username': '<MY_STEAM_USERNAME>'}
getrsa_resp = requests.get(getrsa_url, params=getrsa_data)
response = json.loads(getrsa_resp.text)
if response.get('success'):
steam_publickey_mod = response.get('publickey_mod')
steam_publickey_mod = int(steam_publickey_mod, 16)
steam_publickey_exp = response.get('publickey_exp')
steam_publickey_exp = int(steam_publickey_exp, 16)
steam_rsa_key = RSA.construct((steam_publickey_mod, steam_publickey_exp))
steam_rsa = PKCS115_Cipher(steam_rsa_key)
if steam_rsa_key.can_encrypt():
sessionkey = steam_rsa.encrypt(blob32)
if type(sessionkey) is tuple:
sessionkey = sessionkey[0]
steam_aes = AES.new(blob32)
encrypted_loginkey = steam_aes.encrypt(loginkey)
if all([steamid, sessionkey, encrypted_loginkey]):
authenticate_user_url = (
'https://api.steampowered.com/ISteamUserAuth/AuthenticateUser/v0001')
authenticate_user_json = {
'steamid': steamid,
'sessionkey': sessionkey,
'encrypted_loginkey': encrypted_loginkey,
}
if __name__ == '__main__':
import ipdb
ipdb.set_trace()
authenticate_user_resp = requests.post(url=authenticate_user_url,
data=authenticate_user_json)authenticate_user_resp.ok返回False
authenticate_user_resp.status_code返回403
authenticate_user_resp.reason返回禁忌
对不起,我的英语很差。
发布于 2016-06-18 21:06:17
AuthenticateUser不做你认为它做的事情。蒸汽客户端使用它为当前登录到客户端的用户获取web会话登录cookie。AuthenticateUser请求的loginkey来自CM (客户端连接到的服务器)。
如果要将用户登录到网站,则需要使用HTTP端点进行登录。一旦您拥有了RSA密钥并使用该密钥对您的密码进行了加密,您就可以通过POSTing对https://steamcommunity.com/login/dologin/进行身份验证,并在正文中使用这些urlencoded参数进行身份验证:
captcha_text -空字符串或提示您的验证码文本captchagid --提示您的验证码的GID,或者-1 (如果您还没有得到提示)emailauth -蒸汽保护代码发送到您的电子邮件地址,或空字符串如果不适用emailsteamid -空字符串loginfriendlyname -空字符串password -您的密码,用RSA公钥加密,以及在base64中产生的密文。remember_login - true (如果您想要记住您的登录)或false (如果不记得)(字符串true和false)rsatimestamp -你用RSA密钥得到的时间戳twofactorcode -从您的移动应用程序获得的TOTP代码,如果不适用,则为空字符串。username -您的帐户名发布于 2016-06-12 14:57:44
就我而言,你不被允许做这个操作,因此"403被禁止“,所以,你根本没有”授权“用你拥有的凭据来执行这个操作。
403份答复一般表明以下两个条件之一: 提供了身份验证,但不允许经过身份验证的用户执行请求的操作。该操作禁止所有用户使用。例如,当目录列表被禁用时,对目录列表的请求返回代码403。
https://stackoverflow.com/questions/37775604
复制相似问题