From cb78871ffa29acd2fc1722898b909652b63cfc5b Mon Sep 17 00:00:00 2001 From: James Edington Date: Sun, 21 Feb 2021 19:26:46 -0600 Subject: [PATCH] Correct TOTP URI Steam requires a 5-digit code, but most TOTP software has 6 digits as the default when a length is not specified. --- steam/guard.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/steam/guard.py b/steam/guard.py index b4169d4..d1a19dc 100644 --- a/steam/guard.py +++ b/steam/guard.py @@ -49,6 +49,7 @@ import json import subprocess import struct import requests +import re from base64 import b64decode, b64encode from binascii import hexlify from time import time @@ -179,6 +180,12 @@ class SteamAuthenticator(object): if resp['status'] != EResult.OK: raise SteamAuthenticatorError("Failed to add authenticator. Error: %s" % repr(EResult(resp['status']))) + try: + if not re.search('[&\?].*digits', resp['uri']): + resp['uri'] += '&digits=5' + except KeyError, AttributeError: + pass + self.secrets = resp self.steam_time_offset = int(resp['server_time']) - time()