steamguard


Namesteamguard JSON
Version 1.0.6 PyPI version JSON
download
home_pagehttps://github.com/th3poli/steamguard
SummarySimple Python module to add a phone number to your steam account and enable mobile authentication. It also generates Steam Guard codes, send and confirm tradeoffer and much more!
upload_time2024-08-25 10:14:26
maintainerNone
docs_urlNone
authorth3poli
requires_pythonNone
licenseMIT
keywords steam mobile auth guard steamcommunity tradeoffer
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Steamguard

**Steamguard** is a simple python module to add a phone number to your steam account and enable mobile auth. Also generate steam guard codes.

## Installing Steamguard

Steamguard is available on PyPI:

```console
$ python -m pip install steamguard
```

Below you have Examples and also Tricks & Tips (tradeoffers confirmations, fetching inventory and more)

## Examples

1. Add phone number and mobile steam guard

```python
from steamguard import SteamMobile, LoginConfirmType

mobile = SteamMobile('<steam login>', '<steam password>')

mobile.get_steampowered()
mobile.get_steamcommunity()

code_type = mobile.login()

if code_type == LoginConfirmType.none:
    mobile.confirm_login()

elif code_type == LoginConfirmType.email:
    email_code = input('Enter Steam Guard Code Email > ')
    mobile.confirm_login(email_code)

elif code_type == LoginConfirmType.mobile:
    mobile_code = mobile.generate_steam_guard_code() or input('Enter Steam Guard Code Mobile > ')
    mobile.confirm_login(mobile_code)

data = mobile.export()
mobile.save_exported_data(data, f'{mobile.account_name}_cookies.json')

mobile.add_phone_number('12', '123456789')

input('I clicked the link sent to my email > ')
mobile.add_phone_number_email_verified()

sms_code = input('SMS Code > ')
mobile.add_phone_number_sms_code(sms_code)

mobile.add_mobile_auth()

# SAVE data_mobile! If you lose it, you'll lose access to your account!
data_mobile = mobile.export_mobile()
mobile.save_exported_data(data_mobile, f'{mobile.account_name}_mobile.json')

sms_code_confirm = input('SMS Code Confirm > ')
mobile.add_mobile_auth_confirm(sms_code_confirm)
```

2. Add mobile steam guard without phone number

```python
from steamguard import SteamMobile, LoginConfirmType

mobile = SteamMobile('<steam login>', '<steam password>')

mobile.get_steampowered()
mobile.get_steamcommunity()

code_type = mobile.login()

if code_type == LoginConfirmType.none:
    mobile.confirm_login()

elif code_type == LoginConfirmType.email:
    email_code = input('Enter Steam Guard Code Email > ')
    mobile.confirm_login(email_code)

elif code_type == LoginConfirmType.mobile:
    mobile_code = mobile.generate_steam_guard_code() or input('Enter Steam Guard Code Mobile > ')
    mobile.confirm_login(mobile_code)

data = mobile.export()
mobile.save_exported_data(data, f'{mobile.account_name}_cookies.json')

mobile.add_mobile_auth()

# SAVE data_mobile! If you lose it, you'll lose access to your account!
data_mobile = mobile.export_mobile()
mobile.save_exported_data(data_mobile, f'{mobile.account_name}_mobile.json')

email_code_confirm = input('Email Code Confirm > ')
mobile.add_mobile_auth_confirm(email_code_confirm)
```

3. Load <account_name>_mobile.json and generate steam guard code

```python
from steamguard import SteamMobile

mobile = SteamMobile('<steam login>', '')

mobile_data = mobile.load_exported_data(f'{mobile.account_name}_mobile.json')
mobile.load_mobile(mobile_data)

guard_code = mobile.generate_steam_guard_code()
print(guard_code)
```

## Tricks & Tips

You can change the default path for steamguard files
```python
from steamguard import SteamMobile

mobile = SteamMobile('<steam login>', '<steam password>')

mobile.default_folder = '<MY_FOLDER_PATH>'
```

I want to load previous session saved to <account_name>_cookies.json
```python
from steamguard import SteamMobile

mobile = SteamMobile('<steam login>', '<steam password>')

data = mobile.load_exported_data(f'{mobile.account_name}_cookies.json')
mobile.load(data)

mobile_data = mobile.load_exported_data(f'{mobile.account_name}_mobile.json')
mobile.load_mobile(mobile_data)

mobile.refresh_access_token()
```

I want to fetch my inventory
```python
import steamguard
from steamguard import SteamMobile

mobile = SteamMobile('<steam login>', '<steam password>')

data = mobile.load_exported_data(f'{mobile.account_name}_cookies.json')
mobile.load(data)

mobile.refresh_access_token()

res = steamguard.get_inventory(mobile.session, mobile.steamid)
print(res.json())

# SOMEONE ELSE INVENTORY
res2 = steamguard.get_inventory(mobile.session, '<steamid>')
print(res2.json())
```

I want to get my trade link
```python
import steamguard
from steamguard import SteamMobile

mobile = SteamMobile('<steam login>', '<steam password>')

data = mobile.load_exported_data(f'{mobile.account_name}_cookies.json')
mobile.load(data)

mobile.refresh_access_token()

tradelink = steamguard.get_tradelink(mobile.session)
print('My tradelink is:', tradelink)
```

I want to send a trade offer (this example will send ALL TRADEABLE ITEMS)
```python
import steamguard
from steamguard import SteamMobile

mobile = SteamMobile('<steam login>', '<steam password>')

data = mobile.load_exported_data(f'{mobile.account_name}_cookies.json')
mobile.load(data)

mobile.refresh_access_token()

tradeable_items = steamguard.get_tradeable_inventory(mobile.session, mobile.steamid)

if not len(tradeable_items):
    print('No items to send :(')
else:
    res = steamguard.send_tradeoffer(mobile.session, partner_steamid, tradeoffer_token, tradeable_items, 'My custom message :)') # I don't know if tradeoffer_token is necessary if we're friends
    if res.status_code != 200:
        print(f'Error -> ({res.status_code}) {res.text}')
    else:
        d = res.json()
        tradeofferid = d.get('tradeofferid')

        confirm_type = 'Mobile Confirm' if d.get('needs_mobile_confirmation') else 'Email Confirm'
        print(f'Tradeoffer {tradeofferid} sent, now confirm it -> {confirm_type}')
```

Fetch and confirm pending tradeoffers
```python
from steamguard import SteamMobile

mobile = SteamMobile('<steam login>', '<steam password>')

data = mobile.load_exported_data(f'{mobile.account_name}_cookies.json')
mobile.load(data)

mobile_data = mobile.load_exported_data(f'{mobile.account_name}_mobile.json')
mobile.load_mobile(mobile_data)

mobile.refresh_access_token()

res = mobile.get_trade_confirmations()
data = res.json()
if not data.get('success'):
    print(mobile.account_name, res, data)
else:
    for d in data.get('conf'):
        headline = d.get('headline')
        offerid = d.get('id')
        nonce = d.get('nonce')
        print(f'Trading with: {headline} ({offerid})')
        res2 = mobile._send_confirmation(offerid, nonce)
        if res2.get('success'): print(f'Tradeoffer sent! ({headline})')
        else: print('Failed to confirm tradeoffer', res2)
```

:)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/th3poli/steamguard",
    "name": "steamguard",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "steam, mobile, auth, guard, steamcommunity, tradeoffer",
    "author": "th3poli",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/a0/81/c18046e257eb0d47f247a88d2683b38d5f2fbe5a1992c5704ebed6e4ae91/steamguard-1.0.6.tar.gz",
    "platform": null,
    "description": "# Steamguard\r\n\r\n**Steamguard** is a simple python module to add a phone number to your steam account and enable mobile auth. Also generate steam guard codes.\r\n\r\n## Installing Steamguard\r\n\r\nSteamguard is available on PyPI:\r\n\r\n```console\r\n$ python -m pip install steamguard\r\n```\r\n\r\nBelow you have Examples and also Tricks & Tips (tradeoffers confirmations, fetching inventory and more)\r\n\r\n## Examples\r\n\r\n1. Add phone number and mobile steam guard\r\n\r\n```python\r\nfrom steamguard import SteamMobile, LoginConfirmType\r\n\r\nmobile = SteamMobile('<steam login>', '<steam password>')\r\n\r\nmobile.get_steampowered()\r\nmobile.get_steamcommunity()\r\n\r\ncode_type = mobile.login()\r\n\r\nif code_type == LoginConfirmType.none:\r\n    mobile.confirm_login()\r\n\r\nelif code_type == LoginConfirmType.email:\r\n    email_code = input('Enter Steam Guard Code Email > ')\r\n    mobile.confirm_login(email_code)\r\n\r\nelif code_type == LoginConfirmType.mobile:\r\n    mobile_code = mobile.generate_steam_guard_code() or input('Enter Steam Guard Code Mobile > ')\r\n    mobile.confirm_login(mobile_code)\r\n\r\ndata = mobile.export()\r\nmobile.save_exported_data(data, f'{mobile.account_name}_cookies.json')\r\n\r\nmobile.add_phone_number('12', '123456789')\r\n\r\ninput('I clicked the link sent to my email > ')\r\nmobile.add_phone_number_email_verified()\r\n\r\nsms_code = input('SMS Code > ')\r\nmobile.add_phone_number_sms_code(sms_code)\r\n\r\nmobile.add_mobile_auth()\r\n\r\n# SAVE data_mobile! If you lose it, you'll lose access to your account!\r\ndata_mobile = mobile.export_mobile()\r\nmobile.save_exported_data(data_mobile, f'{mobile.account_name}_mobile.json')\r\n\r\nsms_code_confirm = input('SMS Code Confirm > ')\r\nmobile.add_mobile_auth_confirm(sms_code_confirm)\r\n```\r\n\r\n2. Add mobile steam guard without phone number\r\n\r\n```python\r\nfrom steamguard import SteamMobile, LoginConfirmType\r\n\r\nmobile = SteamMobile('<steam login>', '<steam password>')\r\n\r\nmobile.get_steampowered()\r\nmobile.get_steamcommunity()\r\n\r\ncode_type = mobile.login()\r\n\r\nif code_type == LoginConfirmType.none:\r\n    mobile.confirm_login()\r\n\r\nelif code_type == LoginConfirmType.email:\r\n    email_code = input('Enter Steam Guard Code Email > ')\r\n    mobile.confirm_login(email_code)\r\n\r\nelif code_type == LoginConfirmType.mobile:\r\n    mobile_code = mobile.generate_steam_guard_code() or input('Enter Steam Guard Code Mobile > ')\r\n    mobile.confirm_login(mobile_code)\r\n\r\ndata = mobile.export()\r\nmobile.save_exported_data(data, f'{mobile.account_name}_cookies.json')\r\n\r\nmobile.add_mobile_auth()\r\n\r\n# SAVE data_mobile! If you lose it, you'll lose access to your account!\r\ndata_mobile = mobile.export_mobile()\r\nmobile.save_exported_data(data_mobile, f'{mobile.account_name}_mobile.json')\r\n\r\nemail_code_confirm = input('Email Code Confirm > ')\r\nmobile.add_mobile_auth_confirm(email_code_confirm)\r\n```\r\n\r\n3. Load <account_name>_mobile.json and generate steam guard code\r\n\r\n```python\r\nfrom steamguard import SteamMobile\r\n\r\nmobile = SteamMobile('<steam login>', '')\r\n\r\nmobile_data = mobile.load_exported_data(f'{mobile.account_name}_mobile.json')\r\nmobile.load_mobile(mobile_data)\r\n\r\nguard_code = mobile.generate_steam_guard_code()\r\nprint(guard_code)\r\n```\r\n\r\n## Tricks & Tips\r\n\r\nYou can change the default path for steamguard files\r\n```python\r\nfrom steamguard import SteamMobile\r\n\r\nmobile = SteamMobile('<steam login>', '<steam password>')\r\n\r\nmobile.default_folder = '<MY_FOLDER_PATH>'\r\n```\r\n\r\nI want to load previous session saved to <account_name>_cookies.json\r\n```python\r\nfrom steamguard import SteamMobile\r\n\r\nmobile = SteamMobile('<steam login>', '<steam password>')\r\n\r\ndata = mobile.load_exported_data(f'{mobile.account_name}_cookies.json')\r\nmobile.load(data)\r\n\r\nmobile_data = mobile.load_exported_data(f'{mobile.account_name}_mobile.json')\r\nmobile.load_mobile(mobile_data)\r\n\r\nmobile.refresh_access_token()\r\n```\r\n\r\nI want to fetch my inventory\r\n```python\r\nimport steamguard\r\nfrom steamguard import SteamMobile\r\n\r\nmobile = SteamMobile('<steam login>', '<steam password>')\r\n\r\ndata = mobile.load_exported_data(f'{mobile.account_name}_cookies.json')\r\nmobile.load(data)\r\n\r\nmobile.refresh_access_token()\r\n\r\nres = steamguard.get_inventory(mobile.session, mobile.steamid)\r\nprint(res.json())\r\n\r\n# SOMEONE ELSE INVENTORY\r\nres2 = steamguard.get_inventory(mobile.session, '<steamid>')\r\nprint(res2.json())\r\n```\r\n\r\nI want to get my trade link\r\n```python\r\nimport steamguard\r\nfrom steamguard import SteamMobile\r\n\r\nmobile = SteamMobile('<steam login>', '<steam password>')\r\n\r\ndata = mobile.load_exported_data(f'{mobile.account_name}_cookies.json')\r\nmobile.load(data)\r\n\r\nmobile.refresh_access_token()\r\n\r\ntradelink = steamguard.get_tradelink(mobile.session)\r\nprint('My tradelink is:', tradelink)\r\n```\r\n\r\nI want to send a trade offer (this example will send ALL TRADEABLE ITEMS)\r\n```python\r\nimport steamguard\r\nfrom steamguard import SteamMobile\r\n\r\nmobile = SteamMobile('<steam login>', '<steam password>')\r\n\r\ndata = mobile.load_exported_data(f'{mobile.account_name}_cookies.json')\r\nmobile.load(data)\r\n\r\nmobile.refresh_access_token()\r\n\r\ntradeable_items = steamguard.get_tradeable_inventory(mobile.session, mobile.steamid)\r\n\r\nif not len(tradeable_items):\r\n    print('No items to send :(')\r\nelse:\r\n    res = steamguard.send_tradeoffer(mobile.session, partner_steamid, tradeoffer_token, tradeable_items, 'My custom message :)') # I don't know if tradeoffer_token is necessary if we're friends\r\n    if res.status_code != 200:\r\n        print(f'Error -> ({res.status_code}) {res.text}')\r\n    else:\r\n        d = res.json()\r\n        tradeofferid = d.get('tradeofferid')\r\n\r\n        confirm_type = 'Mobile Confirm' if d.get('needs_mobile_confirmation') else 'Email Confirm'\r\n        print(f'Tradeoffer {tradeofferid} sent, now confirm it -> {confirm_type}')\r\n```\r\n\r\nFetch and confirm pending tradeoffers\r\n```python\r\nfrom steamguard import SteamMobile\r\n\r\nmobile = SteamMobile('<steam login>', '<steam password>')\r\n\r\ndata = mobile.load_exported_data(f'{mobile.account_name}_cookies.json')\r\nmobile.load(data)\r\n\r\nmobile_data = mobile.load_exported_data(f'{mobile.account_name}_mobile.json')\r\nmobile.load_mobile(mobile_data)\r\n\r\nmobile.refresh_access_token()\r\n\r\nres = mobile.get_trade_confirmations()\r\ndata = res.json()\r\nif not data.get('success'):\r\n    print(mobile.account_name, res, data)\r\nelse:\r\n    for d in data.get('conf'):\r\n        headline = d.get('headline')\r\n        offerid = d.get('id')\r\n        nonce = d.get('nonce')\r\n        print(f'Trading with: {headline} ({offerid})')\r\n        res2 = mobile._send_confirmation(offerid, nonce)\r\n        if res2.get('success'): print(f'Tradeoffer sent! ({headline})')\r\n        else: print('Failed to confirm tradeoffer', res2)\r\n```\r\n\r\n:)\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Simple Python module to add a phone number to your steam account and enable mobile authentication. It also generates Steam Guard codes, send and confirm tradeoffer and much more!",
    "version": "1.0.6",
    "project_urls": {
        "Homepage": "https://github.com/th3poli/steamguard"
    },
    "split_keywords": [
        "steam",
        " mobile",
        " auth",
        " guard",
        " steamcommunity",
        " tradeoffer"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d43728a76d8e745dc28674a9c8ab661a02cf88795b0e2b6938d1ef4bb13b87ed",
                "md5": "785441724ddddbb9eca5f4ebc22fc723",
                "sha256": "db3fbdc982be4449bd867c7b1df2e9ba53b7ea0ab34556d1a3486f898f37d638"
            },
            "downloads": -1,
            "filename": "steamguard-1.0.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "785441724ddddbb9eca5f4ebc22fc723",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 12491,
            "upload_time": "2024-08-25T10:14:25",
            "upload_time_iso_8601": "2024-08-25T10:14:25.893464Z",
            "url": "https://files.pythonhosted.org/packages/d4/37/28a76d8e745dc28674a9c8ab661a02cf88795b0e2b6938d1ef4bb13b87ed/steamguard-1.0.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a081c18046e257eb0d47f247a88d2683b38d5f2fbe5a1992c5704ebed6e4ae91",
                "md5": "d7ee1390827d509e93f089a61fc67740",
                "sha256": "a45d3c42d3a9e9fd36b636cccdd3140915d71cf50a0d9842bd5dd9fcd4cb78c1"
            },
            "downloads": -1,
            "filename": "steamguard-1.0.6.tar.gz",
            "has_sig": false,
            "md5_digest": "d7ee1390827d509e93f089a61fc67740",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 11442,
            "upload_time": "2024-08-25T10:14:26",
            "upload_time_iso_8601": "2024-08-25T10:14:26.795315Z",
            "url": "https://files.pythonhosted.org/packages/a0/81/c18046e257eb0d47f247a88d2683b38d5f2fbe5a1992c5704ebed6e4ae91/steamguard-1.0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-25 10:14:26",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "th3poli",
    "github_project": "steamguard",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "steamguard"
}
        
Elapsed time: 0.68715s