aboutsummarylogtreecommitdiffstats
path: root/hangups_manual_login.py
diff options
context:
space:
mode:
authorbobpaul2020-02-16 22:58:50 -0600
committerbobpaul2020-02-16 22:58:50 -0600
commit016495dfb3b448bc40445f23845b5ec867c6518c (patch)
tree26355468f9f2243198093397be52e8d508b4edc8 /hangups_manual_login.py
downloadaur-016495dfb3b448bc40445f23845b5ec867c6518c.tar.gz
Initial commit
Diffstat (limited to 'hangups_manual_login.py')
-rw-r--r--hangups_manual_login.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/hangups_manual_login.py b/hangups_manual_login.py
new file mode 100644
index 000000000000..09c93f71ae58
--- /dev/null
+++ b/hangups_manual_login.py
@@ -0,0 +1,16 @@
+import os, hangups, requests, appdirs
+
+print('Open this URL:')
+print(hangups.auth.OAUTH2_LOGIN_URL)
+
+authorization_code = input('Enter oauth_code cookie value: ')
+
+with requests.Session() as session:
+ session.headers = {'user-agent': hangups.auth.USER_AGENT}
+ access_token, refresh_token = hangups.auth._auth_with_code(
+ session, authorization_code
+ )
+
+dirs = appdirs.AppDirs('hangups', 'hangups')
+token_path = os.path.join(dirs.user_cache_dir, 'refresh_token.txt')
+hangups.auth.RefreshTokenCache(token_path).set(refresh_token)