Skip to content

Instantly share code, notes, and snippets.

Created August 24, 2017 20:36
Show Gist options
  • Save anonymous/0c34af68bf2f59fd7d75ecc6c0fa692d to your computer and use it in GitHub Desktop.
Save anonymous/0c34af68bf2f59fd7d75ecc6c0fa692d to your computer and use it in GitHub Desktop.
Retrieve google drive OAuth token from the Windows Registry
from winreg import ConnectRegistry, OpenKey, EnumValue, HKEY_CURRENT_USER
TARGET_KEY = r'SOFTWARE\Google\Drive'
def main():
with ConnectRegistry(None, HKEY_CURRENT_USER) as wr:
GdriveKey = OpenKey(wr, TARGET_KEY)
i = 0
while True:
try:
k, v, _ = EnumValue(GdriveKey, i)
if 'OAuth' in k:
print("Found OAuth token:\n\tOAuth Private Key ID={}\n\tOAuth Key={}".format(k.split("_")[1], v))
except:
break
else:
i += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment