Asynchronous python library for Steam authorization using protobuf
Project description
Asynchronous python library for Steam authorization using protobuf
Install
pip install pysteamauth
Usage
from pysteamauth.auth import Steam
async def main():
steam = Steam(
login='login',
password='password',
)
await steam.login_to_steam()
await steam.request('https://steamcommunity.com')
await steam.request('https://store.steampowered.com')
await steam.request('https://help.steampowered.com')
If account have Steam Guard
from pysteamauth.auth import Steam
steam = Steam(
login='login',
password='password',
shared_secret='shared_secret',
)
Cookie storage
Library uses default cookie storage BaseCookieStorage, which stores Steam cookies in application memory.
But you can write own cookie storage. For example, redis storage:
import json
from typing import Dict
from aioredis import Redis
from pysteamauth.abstract import CookieStorageAbstract
from pysteamauth.auth import Steam
class RedisStorage(CookieStorageAbstract):
redis = Redis()
async def set(self, login: str, cookies: Dict) -> None:
await self.redis.set(login, json.dumps(cookies))
async def get(self, login: str, domain: str) -> Dict:
cookies = await self.redis.get(login)
if not cookies:
return {}
return json.loads(cookies).get(domain, {})
async def main():
steam = Steam(
login='login',
password='password',
cookie_storage=RedisStorage(),
)
await steam.login_to_steam()
Error processing
from pysteamauth.auth import Steam
from pysteamauth.errors import SteamError
async def main():
try:
await Steam('login', 'password').login_to_steam()
except SteamError as error:
print(error)
Or
from pysteamauth.auth import Steam
from pysteamauth.errors import SteamError, custom_error_exception
class LoginError(SteamError):
...
class RateLimitExceeded(SteamError):
...
custom_error_exception({
5: LoginError,
84: RateLimitExceeded,
})
async def main():
try:
await Steam('login', 'password').login_to_steam()
except LoginError as error:
print(error)
Output
{'error': 'InvalidPassword', 'code': 5}
Proto files
- https://github.com/SteamDatabase/Protobufs/blob/master/steam/enums.proto
- https://github.com/SteamDatabase/Protobufs/blob/master/steam/steammessages_base.proto
- https://github.com/SteamDatabase/Protobufs/blob/master/steam/steammessages_auth.steamclient.proto
- https://github.com/SteamDatabase/Protobufs/blob/master/steam/steammessages_unified_base.steamclient.proto
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pysteamauth2-1.1.9.tar.gz
(36.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pysteamauth2-1.1.9.tar.gz.
File metadata
- Download URL: pysteamauth2-1.1.9.tar.gz
- Upload date:
- Size: 36.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0c0ca4407952521f2fd58e53a4d91c0e4f879bf09064a25552aa2664c0e399f
|
|
| MD5 |
0bc9178117c7497c7ed13c25dffd7aae
|
|
| BLAKE2b-256 |
9b5b50606769d90932add10fd552045b38ca40a8e4149fbc2c4f07eeffede59d
|
File details
Details for the file pysteamauth2-1.1.9-py3-none-any.whl.
File metadata
- Download URL: pysteamauth2-1.1.9-py3-none-any.whl
- Upload date:
- Size: 40.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7844e4bde54f9d41a23f499b83ff7a523c4003c23d0b4fb3eb9d9e1b0734bd2
|
|
| MD5 |
7d7ab9d9cbfb0a1b891a342d230c35ec
|
|
| BLAKE2b-256 |
fab090884e70b69da54a58761a41054854d46e49e053edad121c198ee91c4861
|