0

I wanted to do test revoking a python script's gmail oath2 tokens, but now I can't restore it to working order.

The script was able to send emails. I then deleted the OAuth 2.0 Client IDs in the Google API console so it couldn't do so anymore.

Now I want to get it to work with a new generated ID. So, I replaced the local JSON file with the new one, but the emails still aren't sent. I guess it's still trying to use the old token. How can I get the system to forget the old token or get it to ask for google_client_id, google_client_secret and google_refresh_token as if it is the first time round?

I'm using yagmail to send the emails with this snippet:

   yag_connection = yagmail.SMTP(user=email_dict["user"],
                       oauth2_file="~/" + "client_secret_.json"
   yag_connection.send(to=email_adress, subject=email_title, contents=email_contents,
             attachments=attachments_list)
DoreenBZ
  • 328
  • 1
  • 8

1 Answers1

0

Managed to get asked for google_client_id, google_client_secret and google_refresh_token when changed oauth2 file location to:

    yag_connection = yagmail.SMTP(user=email_login_dict[username_key],
                       oauth2_file=os.getcwd()+"\\"+"client_secret")
DoreenBZ
  • 328
  • 1
  • 8