-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
difficulty getting oauth file with yagmail #261
Comments
Here's what ChatGPT suggested when I posted your question: It sounds like you are having trouble getting yagmail to work with OAuth2 authentication. This can be a tricky process, but I will do my best to help you troubleshoot the issue. First, make sure that you have followed the steps outlined in the yagmail documentation for setting up OAuth2 authentication. This includes creating a project in the Google Cloud Console, enabling the Gmail API, creating OAuth2 credentials, and configuring yagmail to use the credentials. If you have followed these steps and are still having trouble, there are a few things you can try: Double-check your OAuth2 credentials: Make sure that you have downloaded the JSON file containing your OAuth2 credentials from the Google Cloud Console, and that you have specified the correct path to this file in yagmail. Also, make sure that you have specified the correct email address for the user parameter in yagmail, which should be the same email address associated with the OAuth2 credentials. Check your OAuth2 token: If you are able to authenticate with Google and generate a token, but are still getting errors when trying to use yagmail, it's possible that your OAuth2 token is not being passed correctly to yagmail. You can try manually specifying the token file in yagmail using the oauth2_file parameter. For example: python Check your authorization scopes: The error message you are seeing about "insufficient authentication scopes" suggests that you may not have requested the correct authorization scopes when setting up your OAuth2 credentials. Make sure that you have requested the Gmail API scope https://www.googleapis.com/auth/gmail.send, and that you have authorized your credentials with this scope. You can check this by going to the Google Cloud Console, selecting your project, and clicking on "APIs & Services" > "Credentials". Under "OAuth 2.0 Client IDs", click on your client ID and make sure that the "Authorized redirect URIs" includes urn:ietf:wg:oauth:2.0:oob (if you are using the "installed application" flow) or your actual redirect URI (if you are using the "web application" flow). Also make sure that the "Scopes" section includes the https://www.googleapis.com/auth/gmail.send scope. I hope that these suggestions are helpful in getting your yagmail authentication working with OAuth2. |
were you able to solve this issue? i am facing the same problem now. |
I got it working, and it was really useful, but I need to research the fix. I'm now running my app on Google Cloud Functions and am using Sendgrid, very similar to Yagmail, because there was more documentation for using it with Functions. |
I have a working version. What step did you get to and what problem did you have? The key is navigating to the url posted in the python console which brings up the Google authorization steps BUT ENDS IN WHAT APPEARS TO BE AN ERROR, "This site can’t be reached - localhost refused to connect". You then need to copy the link from this page , the one in your browser window that caused the error, and paste it into your python console at the prompt. |
Dear Github,
I am looking forward to using yagmail, but am having a devil of a time getting authorization to work. After first trying to set my gmail account to less secure, I learned this apparently is no longer allowed and Oauth 2 is required.
My issue is much like the one specified in this thread, . As stated in this post, #143 (comment), it appears that google does not supply the credential file in the correct format. But I tried a bunch of things and each had its own problem.
I am stuck. Relatively new to Oauth2, but it seems others are able to use yagmail. Is there a trick I am missing? I am also new to Github but hope my post gives the right amount of info.
Thanks for any assistance,
Brian
The text was updated successfully, but these errors were encountered: