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!
Project description
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:
$ python -m pip install steamguard
Below you have Examples and also Tricks & Tips (tradeoffers confirmations, fetching inventory and more)
Examples
- Add phone number and mobile steam guard
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)
- Add mobile steam guard without phone number
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)
- Load <account_name>_mobile.json and generate steam guard code
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
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
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
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
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)
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
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)
:)
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
Built Distribution
File details
Details for the file steamguard-1.0.6.tar.gz
.
File metadata
- Download URL: steamguard-1.0.6.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
a45d3c42d3a9e9fd36b636cccdd3140915d71cf50a0d9842bd5dd9fcd4cb78c1
|
|
MD5 |
d7ee1390827d509e93f089a61fc67740
|
|
BLAKE2b-256 |
a081c18046e257eb0d47f247a88d2683b38d5f2fbe5a1992c5704ebed6e4ae91
|
File details
Details for the file steamguard-1.0.6-py3-none-any.whl
.
File metadata
- Download URL: steamguard-1.0.6-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
db3fbdc982be4449bd867c7b1df2e9ba53b7ea0ab34556d1a3486f898f37d638
|
|
MD5 |
785441724ddddbb9eca5f4ebc22fc723
|
|
BLAKE2b-256 |
d43728a76d8e745dc28674a9c8ab661a02cf88795b0e2b6938d1ef4bb13b87ed
|