How to send email using Gmail API (uses OAuth2 and nodemailer)

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ม.ค. 2025

ความคิดเห็น •

  • @mafiacodes
    @mafiacodes  2 ปีที่แล้ว +7

    Refresh tokens may stop working after they are granted, either because:
    The application has a status of 'Testing' and the consent screen is configured for an external user type, causing the token to expire in 7 days
    With reference to Github page: github.com/googleapis/google-api-nodejs-client#readme

    • @cumpaMira
      @cumpaMira 2 ปีที่แล้ว

      I came back for this reason, thank you

    • @ashwinr001
      @ashwinr001 2 ปีที่แล้ว

      @yoursTRULY When i try to publish app, it says Verification not required. but still i'm getting the app not verified warning. What's the procedure to get a token that will not expire?

    • @cumpaMira
      @cumpaMira 2 ปีที่แล้ว +2

      @@ashwinr001 have you solved the problem?

    • @samudramitra4900
      @samudramitra4900 ปีที่แล้ว +2

      @@cumpaMira .. I think I have solved it,.. to prevent this,.. go to ur oauth consent screen and change the status from testing to in production by pressing on PUBLISH

    • @ayuenmadyt
      @ayuenmadyt ปีที่แล้ว

      @@samudramitra4900 did google verify your app because production status require verificcation

  • @rakibdev
    @rakibdev 4 ปีที่แล้ว +76

    These type of videos are rare to find on the internet, focuses on real issue.

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว +6

      Glad you liked it

  • @cisar2218
    @cisar2218 2 ปีที่แล้ว +55

    For anyone who receives 403 at 6:00 has to add gmail account to test users at project's OAuth consent screen.

    • @briansanzio1512
      @briansanzio1512 2 ปีที่แล้ว

      mee too

    • @meowhib
      @meowhib 2 ปีที่แล้ว +1

      Hero ♥

    • @saikiranpatill
      @saikiranpatill 2 ปีที่แล้ว +1

      i was searching for this in the whole comments'

    • @selahadinjemal7138
      @selahadinjemal7138 ปีที่แล้ว

      Thanks bro.

    • @h132wayadandekumar7
      @h132wayadandekumar7 ปีที่แล้ว +1

      Literally i spent 8+ hours on this issue, finally i got solution because of you... Thank You

  • @loretotabio1314
    @loretotabio1314 3 ปีที่แล้ว +27

    No wonder why TH-cam is considered the best university nowadays because there are so many great teachers here, and this channel is a good example. The explanation is very clean and easy to understand. What a great video.

    • @mafiacodes
      @mafiacodes  3 ปีที่แล้ว +1

      Happy to help!

  • @rcdunnii
    @rcdunnii 6 หลายเดือนก่อน +2

    Spent many hours trying to navigate the google oauth setups and using ai, all to no avail. This is first explanation that worked! Many thanks!!!

  • @techsamar
    @techsamar 4 ปีที่แล้ว +34

    Those who are getting authorization error, add your email address in test users section then it will work as it should.

    • @ranoveria
      @ranoveria 4 ปีที่แล้ว +5

      You saved my ass few hours of time :) Thank youuu

    • @LifeWithRilla
      @LifeWithRilla 4 ปีที่แล้ว +2

      You good sir are a saint! Thank you!

    • @KHANSOFFICIAL
      @KHANSOFFICIAL 4 ปีที่แล้ว +2

      Thank you❤️

    • @kavindapathirana9562
      @kavindapathirana9562 4 ปีที่แล้ว +1

      where is that section?

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว +5

      Oauth consent section -> add test user
      Inside google developer console

  • @thinhon54
    @thinhon54 2 ปีที่แล้ว +2

    This video is my life savior. I tried numerous methods but only this one works. Thank you so much!!

  • @PazzoFredus
    @PazzoFredus 3 ปีที่แล้ว +77

    Error 403: access_denied The developer hasn't given you access to this app fix:
    Solution:
    1. Go to your developer console.
    2. Go to OAuth consent screen.
    3. Go to +Add users, under test users.
    4. Add the users for the test (even the owner email address if not working without it)

    • @ayushiparmar9745
      @ayushiparmar9745 3 ปีที่แล้ว

      I am facing same error with my login. What to. Please let me know???????

    • @juhandvan
      @juhandvan 3 ปีที่แล้ว +2

      I ran into the same problem. Thank you so much

    • @rajeshamara
      @rajeshamara 3 ปีที่แล้ว +1

      Thanks for the tip. Really help through this error

    • @MAziz-xd6cp
      @MAziz-xd6cp 3 ปีที่แล้ว

      Thanks a lot. Really help through this error.

    • @craigjohnson8279
      @craigjohnson8279 3 ปีที่แล้ว

      @Pazzo_Fredus. Thanks for the info, that helped me a lot! :)

  • @agehjeremiah
    @agehjeremiah 3 ปีที่แล้ว +7

    You have no idea how helpful this tutorial is for me. Thanks a lot.

  • @Kwuasimoto
    @Kwuasimoto 3 ปีที่แล้ว +13

    This is an extremely detailed and well thought out video, well done man! Made it super easy to think about how to implement this into my website

  • @itsmeahmedlukman
    @itsmeahmedlukman 2 ปีที่แล้ว +10

    Who is here after google removed the less secure option on March 30th 2022?

  • @bhagabatiprasad2612
    @bhagabatiprasad2612 4 ปีที่แล้ว +19

    I can't tell you that how much this video helped me. Thanks a lot. Keep it up!

  • @ThePhysicsTree
    @ThePhysicsTree 3 ปีที่แล้ว +3

    Many many thanks.... Amazingly clear voice.... This coming from a Physics teacher who thinks he is very articulate himself.

  • @ErolAspromatis
    @ErolAspromatis 3 ปีที่แล้ว +4

    I love it when a video like this saves me from jumping off a cliff!

  • @sandeepsingh-ts7xb
    @sandeepsingh-ts7xb 10 หลายเดือนก่อน +1

    Kudos for such a great tutorial. Very well explained, every minute detail covered. It worked in one-go.

  • @evans8245
    @evans8245 4 ปีที่แล้ว +8

    ;) dude, tell people to use environment variables in your tutorials, some people code without really thinking about it, thanks for the video

    • @mohammadyeasinalfahad5468
      @mohammadyeasinalfahad5468 4 ปีที่แล้ว +1

      Yeah I agree too

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว +2

      Well yes, in my nodejs auth jwt series, I made that production ready, so we hv used env variables

  • @Agamista379
    @Agamista379 4 ปีที่แล้ว +6

    thanks a lot for the detailed step by step tutorial, this has helped a lot

  • @danvictor4341
    @danvictor4341 3 ปีที่แล้ว +3

    Thanks, man, this was well explained. You redefined "Do it yourself"

  • @MarshallsDocs
    @MarshallsDocs 3 ปีที่แล้ว +5

    Thank you friend you saved me hours and even days of googling and frustration 👍 great job

  • @JOEREIS1983
    @JOEREIS1983 2 ปีที่แล้ว +1

    hey man. Tks for this. It's save me in my work.
    We used a web system with google cloud function send mail for clients, but, because new polices of google, are necessary Oauth, and break send mails in my site.
    Thanks for shared your knowledge.
    Persons equal you, make a better world.
    sorry for my english.

  • @modern_sapien
    @modern_sapien 3 ปีที่แล้ว +1

    Worked like a charm! This is a great video on forwarding emails using Nodemailer through a gmail account! You covered everything

    • @mafiacodes
      @mafiacodes  3 ปีที่แล้ว +1

      Thanks bro 😎

    • @mafiacodes
      @mafiacodes  3 ปีที่แล้ว

      Thanks again for your support 😊

    • @modern_sapien
      @modern_sapien 3 ปีที่แล้ว +1

      @@mafiacodes you literally saved me hours! Thank you!

  • @graceadjei2099
    @graceadjei2099 3 ปีที่แล้ว +2

    Best video everrrr!!! It worked like a charm! Thanks very, very much bro.

  • @gasinefirst6624
    @gasinefirst6624 ปีที่แล้ว +2

    Great content man.Your videos are well detailed and easy to understand👏👏👏

  • @christianleypoldt8385
    @christianleypoldt8385 3 ปีที่แล้ว +2

    Thanks man! Have struggled with this for hours.

  • @hungvochanh7934
    @hungvochanh7934 2 ปีที่แล้ว +3

    Thanks you very much, you save my day :D I forget to add client id and client secret before generate refresh token. Every documents absolute do not mention this step, so againt thanks you

    • @mafiacodes
      @mafiacodes  2 ปีที่แล้ว

      Subscribe like share

  • @razaqonweb
    @razaqonweb 2 ปีที่แล้ว +2

    This video was super helpful. Everything worked as expected. Thank you very much.

  • @MaisUmSomente
    @MaisUmSomente 4 ปีที่แล้ว +1

    Awsome, congratulations, I was having problems to send email using nodemail, but this tutorial solved my problem, VERY USEFULL -THANKS ;-)

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว

      Glad to hear that

  • @trulymittal
    @trulymittal 3 ปีที่แล้ว +9

    Refresh tokens may stop working after they are granted, either because:
    The application has a status of 'Testing' and the consent screen is configured for an external user type, causing the token to expire in 7 days

    • @devplus7131
      @devplus7131 3 ปีที่แล้ว

      how to solve this issue ????

    • @mafiacodes
      @mafiacodes  3 ปีที่แล้ว

      Publish ur application for verification

    • @danielstill5625
      @danielstill5625 3 ปีที่แล้ว +1

      ​@@mafiacodes Will publishing the app for verification make it stop working for now?? I have it being used for a client's website. Thanks for the video btw.

    • @54.soumyanetrapal5
      @54.soumyanetrapal5 3 ปีที่แล้ว

      @@mafiacodes How to do this?

    • @deepaksarvepalli2344
      @deepaksarvepalli2344 2 ปีที่แล้ว

      @@mafiacodes sir how much time it will take to authorise?

  • @bhavikpunmiya9641
    @bhavikpunmiya9641 หลายเดือนก่อน +1

    Thank you so much ! , you made it so easy for me ! Earned a new Subscriber

  • @Shubham_Patil__
    @Shubham_Patil__ 2 ปีที่แล้ว +2

    Do I need to generate access token & refresh toked every time manually when it gets expired?

  • @rafaelcamaraa
    @rafaelcamaraa 2 หลายเดือนก่อน +1

    If the app is in production mode, will the refresh token stop working, or will it work indefinitely?

  • @drewmcdonald4082
    @drewmcdonald4082 3 ปีที่แล้ว +3

    This is awesome! Thank you for making this!

    • @mafiacodes
      @mafiacodes  3 ปีที่แล้ว

      Subscribe like share

  • @ahmedrahali8019
    @ahmedrahali8019 3 ปีที่แล้ว +3

    The problem is the token expire after some time and i need to repeat the process again to have nez token

  • @wagesapta000
    @wagesapta000 ปีที่แล้ว +1

    can the from email be replaced with client email and to is our email, so it's not us who sends but the money client sends to us?

  • @usama_javed
    @usama_javed 2 ปีที่แล้ว +2

    Very helpful, great job bro ❤❤❤

  • @almedinshala8794
    @almedinshala8794 8 หลายเดือนก่อน +1

    good tutorial, helpful in 2024 for a small project

  • @yerson557
    @yerson557 3 ปีที่แล้ว +1

    Thanks, man! it worked very well, you made a really good job!

  • @yogeshsharma-wl1xj
    @yogeshsharma-wl1xj 3 ปีที่แล้ว

    Awesome video with all needed steps. Thanks a lot , keep it up !!

  • @kushalsinghrathore3890
    @kushalsinghrathore3890 2 ปีที่แล้ว +1

    showing error access denied while on oauth playground authorization and if added that email in test all work well but in nodemailer showing error of wrong username and password but all my credentials are right

  • @mcTraher1
    @mcTraher1 ปีที่แล้ว +2

    Hey man thank you for ure job, very clear and helpful!

  • @leonardocoronel8108
    @leonardocoronel8108 4 ปีที่แล้ว +3

    Thx a lot, great tutorial it works perfectly ! ♥ greetings from Argentina !

    • @danpenia219
      @danpenia219 4 ปีที่แล้ว +1

      Aguante Argentina vieja! No me importa nada

    • @leonardocoronel8108
      @leonardocoronel8108 4 ปีที่แล้ว +1

      @@danpenia219 atr o no papu ? We

  • @abdulrafeyrizwan2981
    @abdulrafeyrizwan2981 3 ปีที่แล้ว +1

    Man.. this tutorial helped me alot.

  • @Biometrics
    @Biometrics 2 ปีที่แล้ว

    Thanks a fortune! I am finally out of the woods. This helped me a great deal.

  • @navtejsingh2731
    @navtejsingh2731 หลายเดือนก่อน

    Great presentation. 👏🏻

  • @54.soumyanetrapal5
    @54.soumyanetrapal5 3 ปีที่แล้ว +1

    Wonderful work... very handy way to send custom mails..

  • @tomchambers9787
    @tomchambers9787 3 ปีที่แล้ว +1

    Fantastic job.. voice is so clear.... do Paterons get access to the code you use on your youtubes? That would add even more value... Thank you for sharing you knowledge.

    • @mafiacodes
      @mafiacodes  3 ปีที่แล้ว +1

      Thank you, my code is all public on GitHub, if someone really likes and wants to support - anyone (even you 😅) can support me on PayPal or patreon.

  • @rizwanmustafa0000
    @rizwanmustafa0000 2 ปีที่แล้ว +1

    Thank you so much for helping me out.

  • @zydricc2647
    @zydricc2647 4 ปีที่แล้ว +3

    For the lads out there that had the error: 'error self signed certificate in certificate chain', its probably your anti virus, either turn it off or to combat this just add the code in your transport:
    auth: {your auth credentials},
    tls : { rejectUnauthorized: false }

    • @arpitanand6534
      @arpitanand6534 3 ปีที่แล้ว

      This is a underrated comment! It worked, thanks🤠

  • @st3114rr
    @st3114rr 3 ปีที่แล้ว +1

    Thanks so much for the great tutorial!

  • @fengming8528
    @fengming8528 3 ปีที่แล้ว +1

    Great tutorial! Thanks for the video.

  • @justadev____7232
    @justadev____7232 3 ปีที่แล้ว +2

    My token keeps expiring after a couple days. I thought the refresh token was to prevent that? How do I get around this? I should also note that I did specify my app's client ID and client secret exactly like you did at 4:55.

    • @vigneshchandrasekhar7387
      @vigneshchandrasekhar7387 3 ปีที่แล้ว

      Same I got a token revoked error after 7 days

    • @justadev____7232
      @justadev____7232 3 ปีที่แล้ว +1

      @@vigneshchandrasekhar7387 Looks like something more than likely changed after video was made.

  • @hashikamaduranga6122
    @hashikamaduranga6122 3 ปีที่แล้ว

    Awesome explanation and good replier for any kind of issue related to the video

  • @jacoboarcemendizabal7036
    @jacoboarcemendizabal7036 3 ปีที่แล้ว

    Thank you very much, a query please, how would it be done in the case of a corporate email (with your own domain) to send emails with nodemailer with google workspace?

  • @deepakmehrotra3426
    @deepakmehrotra3426 3 ปีที่แล้ว +2

    much needed thanks a lot bro!

  • @danielli3288
    @danielli3288 3 ปีที่แล้ว +2

    should the client id, client secret and refresh token be env variables?

  • @РусланЮсуфов-ф3ш
    @РусланЮсуфов-ф3ш 3 ปีที่แล้ว +1

    Thanks a lot, man! You helped me a lot!

  • @mitri-dvp
    @mitri-dvp 4 ปีที่แล้ว +1

    Awesome tutorial man, I appreciate videos like this that show exaclty what to do!
    I do have a question, is there a limit to send emails in this way?

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว +1

      I don't know if there are any but u can use it like as if ur using gmail on the app, if u want to send marketing or transactional emails then I recommend using a mail service, have a look at this video: th-cam.com/video/qFDgH6dHRA4/w-d-xo.html

    • @mitri-dvp
      @mitri-dvp 4 ปีที่แล้ว

      @@mafiacodes Sweet, thanks again for your help

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว

      Subscribe like share

  • @pioSko
    @pioSko 2 ปีที่แล้ว

    It works! Amazing! Thank you! Awesome tutorial!

  • @drB762
    @drB762 3 ปีที่แล้ว +1

    This was excellent. Great job. Thank you.

  • @edmund0dao
    @edmund0dao 3 ปีที่แล้ว

    If it gives you a 403 on the OAuth Playground, could try to click publish OAuth Consent screen. Fixed my issue.

  • @zydricc2647
    @zydricc2647 4 ปีที่แล้ว +1

    Awesome, I was looking for this

  • @princebhattacharya3216
    @princebhattacharya3216 4 ปีที่แล้ว +1

    Thanks for making this video love from developers India

  • @taraskropyvka9044
    @taraskropyvka9044 2 ปีที่แล้ว +1

    Thank you! Saved my time!

  • @jakeairbender8941
    @jakeairbender8941 3 ปีที่แล้ว +1

    Thank you so much! This was exactly what I needed.

    • @mafiacodes
      @mafiacodes  3 ปีที่แล้ว

      Subscribe like share

    • @Clepsydris
      @Clepsydris 2 ปีที่แล้ว +1

      Why do we need this, can you tell the application of it.

  • @gines427
    @gines427 3 ปีที่แล้ว +1

    thanks dude, you are a genius. You helped me a lot

    • @mafiacodes
      @mafiacodes  3 ปีที่แล้ว

      Subscribe like share

  • @worldmusics8096
    @worldmusics8096 3 ปีที่แล้ว +1

    Awesome thank you bro

  • @_dvyne
    @_dvyne 2 ปีที่แล้ว

    Hi, thanks for this tutorial, but this seems not to work in production environment, please do you have any idea how to work around it

  • @Alexis-ul6zc
    @Alexis-ul6zc 3 ปีที่แล้ว +1

    I got stuck at the step of sign in, it says the app isn't verified and I do NOT see the "Advanced" option there.

  • @tamngo2862
    @tamngo2862 3 ปีที่แล้ว +1

    Thank you so much. I did with no error

  • @devsuthar6795
    @devsuthar6795 9 หลายเดือนก่อน

    thank you so much bro very easy to understand and works well

  • @vikramdungarwal7110
    @vikramdungarwal7110 ปีที่แล้ว +1

    Add your emaid id in test users section of OAuth Consent Screen so that it will give you permission to open

  • @phathutshedzomamedzi9820
    @phathutshedzomamedzi9820 3 ปีที่แล้ว +1

    Great tutorial bro

  • @rohanharnale1888
    @rohanharnale1888 3 ปีที่แล้ว +1

    Awesome tutorial. Thanks..

  • @libamlakbirhanu2844
    @libamlakbirhanu2844 3 ปีที่แล้ว

    thank you man, this was really helpful

  • @prathamrajdev3242
    @prathamrajdev3242 ปีที่แล้ว

    Very helpful video. Thank you so much for helping

  • @anushkasaxena2606
    @anushkasaxena2606 3 ปีที่แล้ว

    Thank you so much. It worked in one go!!!

  • @thiagocosta1606
    @thiagocosta1606 2 ปีที่แล้ว

    whoever has problems, just go to
    OAuth consent screen, then add an email for test user.
    ready, then just authorize the process.

  • @SureshS-md5su
    @SureshS-md5su 11 หลายเดือนก่อน

    Thanks a bunch for the detailed video

  • @daman823
    @daman823 2 ปีที่แล้ว +1

    This works perfectly! Thanks......

  • @BarakerZeonlist
    @BarakerZeonlist 4 ปีที่แล้ว +4

    i love this video but in getting error while authorize an api any one help me please !!
    Authorization Error
    Error 403: access_denied
    The developer hasn’t given you access to this app. It’s currently being tested and it hasn’t been verified by Google. If you think you should have access, contact the developer

    • @matasitrattana6456
      @matasitrattana6456 4 ปีที่แล้ว +2

      You try going to the OAuth screen menu in google cloud and hit publish.

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว +5

      Go to developer console and inside the oauth consent add in a test user. And ur good to go.

    • @tijanisylla1348
      @tijanisylla1348 3 ปีที่แล้ว

      @@mafiacodes Thank You good catch

    • @tijanisylla1348
      @tijanisylla1348 3 ปีที่แล้ว

      Thank You good catch

  • @Bewise_person
    @Bewise_person 2 ปีที่แล้ว

    ITS REALLY WORKED LOL THANK YOU DUDE

  • @geetanshrathore4203
    @geetanshrathore4203 3 ปีที่แล้ว

    awesome work keep up with the hard work thanks for the video it helped a lot

  • @nishalk781
    @nishalk781 3 ปีที่แล้ว +1

    Thanks, this helped a lot

  • @prateekchouhan1541
    @prateekchouhan1541 3 ปีที่แล้ว +1

    Thanks for tutorial. Which theme did you use?

  • @dvalley56
    @dvalley56 3 ปีที่แล้ว +1

    Thanks bro, made my day

  • @smartinfotube8724
    @smartinfotube8724 ปีที่แล้ว

    great job. but in my redirect url there is no the advanced option for me as am blocked with access denied! how can get it? could you help me please?

  • @chrismukasa198
    @chrismukasa198 3 ปีที่แล้ว +1

    Thank you so much, you save me 👏🏼👏🏼👏🏼👏🏼👏🏼👏🏼👏🏼👏🏼👏🏼👏🏼

  • @ludmilaschlegelova2333
    @ludmilaschlegelova2333 3 ปีที่แล้ว +1

    Thank you very much, it was trully explained very well :)

  • @streetcloud3941
    @streetcloud3941 3 ปีที่แล้ว +1

    Very nice video, thanks much friend :)

  • @jovankirstenanggata6291
    @jovankirstenanggata6291 2 ปีที่แล้ว

    What is the using of refresh token in order to access the gmail API ? Sorry, I just try this OAuth 2.0 today.......

  • @ismiimen5313
    @ismiimen5313 2 ปีที่แล้ว

    Thank youuuuu so much .. it helps me a lot 🌸🌸😍

  • @TestSf01
    @TestSf01 ปีที่แล้ว

    Can you help me with the steps to read a email. I want to extract the subject of the mail present in inox. Please help

  • @luvdipsinghdadiyala5683
    @luvdipsinghdadiyala5683 2 ปีที่แล้ว

    Thanks It Worked !!! Subscribed

  • @motivateurself9852
    @motivateurself9852 2 ปีที่แล้ว

    Thank You so much. It helped me a lot

  • @valikonen
    @valikonen 3 ปีที่แล้ว

    Thank you so much for your clean explication.

  • @angelabeatrizjavier5454
    @angelabeatrizjavier5454 3 ปีที่แล้ว

    So much help! Thank you for this :>

  • @PawailRana
    @PawailRana 3 ปีที่แล้ว +1

    good job !! you are awesome

  • @shatanandpatil858
    @shatanandpatil858 2 ปีที่แล้ว

    Worked! Thank you very much! keep posting.. how did you add those smileys in vscode?

  • @myWayIn619
    @myWayIn619 10 หลายเดือนก่อน

    Your video helped me alot! could you make one for interacting with google sheets?

  • @sonny5497
    @sonny5497 9 หลายเดือนก่อน

    thank you this was perfect 💯