blob: 09c93f71ae588fcd0114a5a7dfa4b68a8570fe3f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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)
|