No video

Send An Email With Gmail Using Service Account In Python (Gmail API)

  Рет қаралды 22,670

Jie Jenn

Jie Jenn

2 жыл бұрын

In general, when we need to automate Gmail tasks, we need to go through the OAuth2 protocol to authenticate an account (still the best approach on behalf of a user), and going through the authentication can be a bit annoying and troublesome if you want to have a truly automate workflow for Gmail related tasks. Fortunately, by using a Service Account we can skip the verification process.
In this tutorial, I will show you how to send an email using Gmail with a Google Service Account in Python.
▶ Resources
--------------------------------------------------------------------------------------------
📑 Perform Google Workspace Domain-Wide Delegation of Authorit: developers.goo...
📑 Gmail API Reference: developers.goo...
► Buy Me a Coffee? Your support is much appreciated!
-------------------------------------------------------------------------------------------
☕ Paypal: www.paypal.me/...
☕ Venmo: @Jie-Jenn
💸 Join Robinhood with my link and we'll both get a free stock: bit.ly/3iWr7LC
► Support my channel so I can continue making free contents
---------------------------------------------------------------------------------------------------------------
🌳 Becoming a Patreon supporter: / jiejenn
🛒 By shopping on Amazon → amzn.to/2JkGeMD
📘 Facebook Page → / madeinpython
📘 More tutorial videos on my website → LearnDataAnaly...
👩‍💻 Follow me on Linked: / jiejenn
✉️ Business Inquiring: KZfaq@LearnDataAnalysis.org
#GmailAPI #Gmail #Python #ServiceAccount

Пікірлер: 35
@bee_dmytro
@bee_dmytro Жыл бұрын
Tell me please what should I do if I want to get emails from my own gmail? I do not have google admin. But service account does not have access to my gmail, I do not know how give it to him.
@productivetarik
@productivetarik 4 ай бұрын
Thank you for the thorough clarification. I've successfully configured domain-wide delegation, yet I'm encountering the error 'Precondition check failed.' It appears that there might be a delay in being able to impersonate users. Could this be the cause, or is there another issue at play?
@caliosd1836
@caliosd1836 Жыл бұрын
thanks for your admin console part in the video. that saves me a lot!
@shekhar436
@shekhar436 2 жыл бұрын
The code link is not there in description text ?
@gamingislife2545
@gamingislife2545 2 жыл бұрын
Thanks a lot, you explained it really well !
@elricho72
@elricho72 4 ай бұрын
Great video, Could you make an example to see how to list the users of the google admin directory, I follow all your steps, I enable the scopes but I always get an access error, even though I have access to the account as an administrator, I don't understand what permission is missing, for example this video with the created account if you run it without problems. Thank you.
@jiejenn
@jiejenn 4 ай бұрын
I will look into it.
@hugh_dancy
@hugh_dancy Жыл бұрын
hello mr jenn i am unable to follow the part about delegating. is there an extra step to get access to it? i do not know my admin account email and its apparently not the same as the project email?
@juniordeveloper1754
@juniordeveloper1754 2 жыл бұрын
Currently at the moment Google that's not support third party to send emails with other apps like Pycharm. I have tried multiple times. Can anyone help me
@danielleivy8180
@danielleivy8180 2 ай бұрын
I see some comments about using regular gmail. To my knowledge Google took that bit away. You can no longer "allow third party access" and need an actual workspace account to do this.
@jiejenn
@jiejenn 2 ай бұрын
I don't think that information is correct as of today.
@danielleivy8180
@danielleivy8180 2 ай бұрын
​@@jiejenn Sorry I meant 'less secure apps".
@sheepay99
@sheepay99 2 жыл бұрын
Man Google's docs are absolutely terrible
@CarlosRodriguez-ct7xn
@CarlosRodriguez-ct7xn Жыл бұрын
Yes they are
@ericweiss2210
@ericweiss2210 2 жыл бұрын
Thank you for a very informative video. I apologize in advance for this silly question but I have only been working with python and google API's for a few months, total newbie. I recently created a script with access to google sheets API. I want to include email access within the same script. What is the easiest way to do this? Any recommendations would be greatly appreciated.
@jiejenn
@jiejenn 2 жыл бұрын
Hey Eric, can you be more specific?
@ericweiss2210
@ericweiss2210 2 жыл бұрын
@@jiejenn I want to create an application that will access the google sheets, docs , calendar, and drive API within the same python script. How would you go about creating this type of application? I used your video to create an application that performs functions across google sheets API and it worked perfectly thanks to your videos. Any help would be greatly appreciated.
@disguisedfox7491
@disguisedfox7491 9 ай бұрын
Hi there, very late but i think i might have your answer if you still need it! Ex: class DocsAPI(): def send(params): # do stuff class SheetsAPI: def send(params): # do stuff class CalenderAPI:: def send(params): # do stuff So on and so on, include these in there own seperate .py file for better code management and easier use of the APIs also to import these to the main file: import SheetsAPI sheet = SheetsAPI() ect.
@Moist_yet_Crispy
@Moist_yet_Crispy Жыл бұрын
Hey I love you videos, I've noticed that gmail api has changed a bit since you did this tut, Would you be willing to do another tutorial on gmail api since things have changed. No one else has one and I've tried the other videos as well and keep getting stuck. Thanks in advance!
@jiejenn
@jiejenn Жыл бұрын
Thanks for the comment Corey. Can you tell me what have changed with Gmail API?
@Moist_yet_Crispy
@Moist_yet_Crispy Жыл бұрын
@@jiejenn I apologize that I can't at the moment. About 2-3 months ago there was an update to gmail api and my project broke. It was a project I was working on for a start up and I've since walked away from it as larger issues called me away. I was working on automating email order totals to be put into a spread sheet and it went belly up and I wasn't able to figure out why. Is your project still working?
@jiejenn
@jiejenn Жыл бұрын
@@Moist_yet_Crispy yup. My Gmail automations are still running fine.
@Moist_yet_Crispy
@Moist_yet_Crispy Жыл бұрын
@@jiejenn ! Thank you for this!
@farangisranandehgar3355
@farangisranandehgar3355 2 жыл бұрын
Thank you
@full_bearfull_bear4783
@full_bearfull_bear4783 2 жыл бұрын
What is a "workspace account" ? How do we create one? .....
@jiejenn
@jiejenn 2 жыл бұрын
A workspace is basically Google Suite. Maybe this link will provide more information workspace.google.com/?Workspace-APAC-TW-en-BKWS-EXA-Regular&DEV_m-CRE_525364223903-ADGP_Hybrid+%7C+BKWS+-+EXA+%7C+Txt+~+Workspace+-+Temporary-KWID_43700064150896639-kwd-346911454270&userloc_9040379-network_g&KW_google%20workspace&gclid=Cj0KCQjwkruVBhCHARIsACVIiOxlpqyHmbCXhr0P8O-FUGhSk_olALAMgB0uyXqtCj4Hr_9JoJ_WHMMaAonREALw_wcB&gclsrc=aw.ds
@serychristianrenaud
@serychristianrenaud 2 жыл бұрын
Thanks
@Najumulsaqib
@Najumulsaqib Жыл бұрын
Isnt this supported with normal Gmail accounts that are not on workspace?
@jiejenn
@jiejenn Жыл бұрын
Not sure if I understand your question.
@bee_dmytro
@bee_dmytro Жыл бұрын
@@jiejenn He said that there is a problem with delegation process if you want to work with private gmail, without google admin access.
@user-fr4tn8ty8b
@user-fr4tn8ty8b Жыл бұрын
Excelent!!!
@productivetarik
@productivetarik 4 ай бұрын
Thank you for the thorough clarification. I've successfully configured domain-wide delegation, yet I'm encountering the error 'Precondition check failed.' It appears that there might be a delay in being able to impersonate users. Could this be the cause, or is there another issue at play?
@jiejenn
@jiejenn 4 ай бұрын
This may help stackoverflow.com/questions/77300161/getting-precondition-check-failed-when-using-gmail-api-with-a-service-account
@productivetarik
@productivetarik 4 ай бұрын
​@@jiejennthanks for replying, the problem was that i was creating the credentials object using the way in the documentation and this seems to raise the issue, but i used the way you mentioned in the video and it worked fine
Getting Started With Google APIs For Python Development
22:37
AMT2 - Extracting Emails from your Gmail Inbox using python
16:02
DigitalSreeni
Рет қаралды 33 М.
Stay on your way 🛤️✨
00:34
A4
Рет қаралды 31 МЛН
Smart Sigma Kid #funny #sigma #comedy
00:40
CRAZY GREAPA
Рет қаралды 37 МЛН
Jumping off balcony pulls her tooth! 🫣🦷
01:00
Justin Flom
Рет қаралды 34 МЛН
How to send email using Gmail API (uses OAuth2 and nodemailer)
17:55
Automate Google Sheets With Python - Google Sheets API Tutorial
32:28
How to Send Emails with Python [New Method 2023]
11:16
The PyCoach
Рет қаралды 185 М.
Always Check for the Hidden API when Web Scraping
11:50
John Watson Rooney
Рет қаралды 617 М.
Sending Email using Python in 5 statements
9:53
Telusko
Рет қаралды 230 М.
How to Connect a Personal Gmail Account to Make (Integromat)
12:42
XRay Automation
Рет қаралды 10 М.
Stay on your way 🛤️✨
00:34
A4
Рет қаралды 31 МЛН