Closed mourgaya closed 7 years ago
Hey, thanks for posting.
Just to make sure: did you try deleting client_secret.json
and have yagmail
create it from the ground up?
hello,
Thanks a lot it works now.
good job.
I have just included the following code in yagmail in order to support a JSON file format:
def get_oauth_string(user, oauth2_info):
client_id = oauth2_info['google_client_id']
client_secret = oauth2_info['google_client_secret']
rtoken = oauth2_info['google_refresh_token']
access_token, expires_in = refresh_authorization(
client_id, client_secret, rtoken
)
auth_string = generate_oauth2_string(user, access_token, as_base64=True)
return auth_string
I think that either something like this or publishing the format for the JSON file that yagmail expects would be highly appreciated by beginners like me.
Please let me know which solution you find more useful! I can help in writing documentation if you want!
Hello, I would like to use oauth2, so I have created an id with option "web type" and also try with an "application type", but both failed.
The id web type failed with this message:
Traceback (most recent call last): File "testgmail.py", line 3, in
yag = yagmail.SMTP("eyyyy.xxxxxxx@gmail.com", oauth2_file="~/client_secret.json")
File "/usr/local/lib/python2.7/dist-packages/yagmail-0.9.179-py2.7.egg/yagmail/sender.py", line 74, in init
self.login_oauth2(oauth2_file)
File "/usr/local/lib/python2.7/dist-packages/yagmail-0.9.179-py2.7.egg/yagmail/sender.py", line 198, in login_oauth2
auth_string = get_oauth_string(self.user, oauth2_info)
File "/usr/local/lib/python2.7/dist-packages/yagmail-0.9.179-py2.7.egg/yagmail/oauth2.py", line 96, in get_oauth_string
access_token, expires_in = refresh_authorization(**oauth2_info)
TypeError: refresh_authorization() got an unexpected keyword argument 'web'
I think the json file is not the good one with yagmail, can you help me with these input?
---------------------------------------------cllient_secret.json {"web":{"client_id":"xxxxxxx.apps.googleusercontent.com","project_id":"inspired-iiiuuuuu","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://accounts.google.com/o/oauth2/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"TTTTTTbbskn"}}
and -----------------------------------------------------testgmail.py import yagmail
yag = yagmail.SMTP("yyyy.zzzzzzz@gmail.com", oauth2_file="~/client_secret.json")