mirror of
https://github.com/jayofelony/pwnagotchi.git
synced 2025-07-01 18:37:27 -04:00
@ -34,7 +34,7 @@ def handle_cmd(args):
|
|||||||
if args.plugincmd == 'auth':
|
if args.plugincmd == 'auth':
|
||||||
return auth()
|
return auth()
|
||||||
elif args.plugincmd == 'refresh':
|
elif args.plugincmd == 'refresh':
|
||||||
return refresh(args)
|
return refresh()
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
|
||||||
@ -57,35 +57,34 @@ def auth():
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def refresh(args):
|
def refresh():
|
||||||
if int(args):
|
# refresh token for x amount of time (seconds)
|
||||||
# refresh token for x amount of time (seconds)
|
gauth = GoogleAuth(settings_file="settings.yaml")
|
||||||
gauth = GoogleAuth(settings_file="settings.yaml")
|
try:
|
||||||
try:
|
# Try to load saved client credentials
|
||||||
# Try to load saved client credentials
|
gauth.LoadCredentialsFile("credentials.json")
|
||||||
gauth.LoadCredentialsFile("credentials.json")
|
except pydrive2.auth.InvalidCredentialsError:
|
||||||
except pydrive2.auth.InvalidCredentialsError:
|
print(gauth.GetAuthUrl())
|
||||||
print(gauth.GetAuthUrl())
|
user_input = input("Please copy this URL into a browser, "
|
||||||
user_input = input("Please copy this URL into a browser, "
|
"complete the verification and then copy/paste the code from addressbar.")
|
||||||
"complete the verification and then copy/paste the code from addressbar.")
|
gauth.Auth(user_input)
|
||||||
gauth.Auth(user_input)
|
|
||||||
|
|
||||||
if gauth.access_token_expired:
|
if gauth.access_token_expired:
|
||||||
if gauth.credentials is not None:
|
if gauth.credentials is not None:
|
||||||
try:
|
try:
|
||||||
# Refresh the token
|
# Refresh the token
|
||||||
gauth.Refresh()
|
gauth.Refresh()
|
||||||
except pydrive2.auth.RefreshError:
|
except pydrive2.auth.RefreshError:
|
||||||
print(gauth.GetAuthUrl())
|
|
||||||
user_input = input("Please copy this URL into a browser, "
|
|
||||||
"complete the verification and then copy/paste the code from addressbar.")
|
|
||||||
gauth.Auth(user_input)
|
|
||||||
else:
|
|
||||||
print(gauth.GetAuthUrl())
|
print(gauth.GetAuthUrl())
|
||||||
user_input = input("Please copy this URL into a browser, "
|
user_input = input("Please copy this URL into a browser, "
|
||||||
"complete the verification and then copy/paste the code from addressbar.")
|
"complete the verification and then copy/paste the code from addressbar.")
|
||||||
gauth.Auth(user_input)
|
gauth.Auth(user_input)
|
||||||
gauth.Authorize()
|
else:
|
||||||
gauth.SaveCredentialsFile("credentials.json")
|
print(gauth.GetAuthUrl())
|
||||||
print("No refresh is required.")
|
user_input = input("Please copy this URL into a browser, "
|
||||||
|
"complete the verification and then copy/paste the code from addressbar.")
|
||||||
|
gauth.Auth(user_input)
|
||||||
|
gauth.Authorize()
|
||||||
|
gauth.SaveCredentialsFile("credentials.json")
|
||||||
|
print("No refresh is required.")
|
||||||
return 0
|
return 0
|
||||||
|
Reference in New Issue
Block a user