Skip to main content

Asynchronous python library for Steam authorization using protobuf

Project description

Asynchronous python library for Steam authorization using protobuf

pypi: package Python: versions

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

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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pysteamauth2-1.1.9-py3-none-any.whl (40.6 kB view details)

Uploaded Python 3

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

Hashes for pysteamauth2-1.1.9.tar.gz
Algorithm Hash digest
SHA256 d0c0ca4407952521f2fd58e53a4d91c0e4f879bf09064a25552aa2664c0e399f
MD5 0bc9178117c7497c7ed13c25dffd7aae
BLAKE2b-256 9b5b50606769d90932add10fd552045b38ca40a8e4149fbc2c4f07eeffede59d

See more details on using hashes here.

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

Hashes for pysteamauth2-1.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 b7844e4bde54f9d41a23f499b83ff7a523c4003c23d0b4fb3eb9d9e1b0734bd2
MD5 7d7ab9d9cbfb0a1b891a342d230c35ec
BLAKE2b-256 fab090884e70b69da54a58761a41054854d46e49e053edad121c198ee91c4861

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page