Skip to content

Commit

Permalink
Merge pull request #214 from NicDom/master
Browse files Browse the repository at this point in the history
Fix [#213]
  • Loading branch information
kootenpv authored Aug 30, 2021
2 parents d6a5952 + 27d9b00 commit 8eb3a05
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions yagmail/oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,22 @@ def get_oauth2_info(oauth2_file):
if os.path.isfile(oauth2_file):
with open(oauth2_file) as f:
oauth2_info = json.load(f)
try:
oauth2_info = oauth2_info["installed"]
except KeyError:
return oauth2_info
email_addr = input("Your 'email address': ")
google_client_id = oauth2_info["client_id"]
google_client_secret = oauth2_info["client_secret"]
google_refresh_token, _, _ = get_authorization(google_client_id, google_client_secret)
oauth2_info = {
"email_address": email_addr,
"google_client_id": google_client_id.strip(),
"google_client_secret": google_client_secret.strip(),
"google_refresh_token": google_refresh_token.strip(),
}
with open(oauth2_file, "w") as f:
json.dump(oauth2_info, f)
else:
print("If you do not have an app registered for your email sending purposes, visit:")
print("https://console.developers.google.com")
Expand Down

0 comments on commit 8eb3a05

Please sign in to comment.