How to fetch Gmail Subject & Body using Gmail APIs || Gmail OAuth 2.0 APIs || NaveenAutomationLabs

  Рет қаралды 49,171

Naveen AutomationLabs

Naveen AutomationLabs

4 жыл бұрын

In this video, I have explained how to read emails from gmail domain using gmail apis.
Gmail uses OAuth 2.0 APIs to read/write the mail.
The Gmail API is a RESTful API that can be used to access Gmail mailboxes and send mail. For most web applications (including mobile apps), the Gmail API is the best choice for authorized access to a user's Gmail data.
Please find this GIT repo for the full code:
github.com/naveenanimation20/...
You can refer this Gmail API Guide:
developers.google.com/gmail/a...
========
~~Subscribe to this channel, and press bell icon to get some interesting videos on Selenium and Automation:
kzfaq.info%20Au...
Follow me on my Facebook Page:
/ naveenqtpexpert
Let's join our Automation community for some amazing knowledge sharing and group discussion on Telegram:
t.me/joinchat/COJqZUPB02r5sB7...
Paid courses (Recorded) videos:
naveenautomationlabs.com/reco...
For Java & Selenium - naveenautomationlabs.com/selen...
For API (Manual + Automation) - naveenautomationlabs.com/manua...

Пікірлер: 107
@dnyaneshwarrathod5341
@dnyaneshwarrathod5341 4 жыл бұрын
Hey, Naveen many many congrats for your achievement... There are very rare people like you who share such great knowledge... Thanks
@Dischade
@Dischade 4 ай бұрын
Checking in to this very old video, this was a lifesaver thank you very much. Especially thanks for putting your project on git!
@tusharsingh6035
@tusharsingh6035 3 жыл бұрын
Thank You Naveen sir for this video. thanks a lot.
@Dischade
@Dischade 4 ай бұрын
Thanks! I learned SO much from your demo, this helped me greatly.
@rajputyuvraj6558
@rajputyuvraj6558 4 жыл бұрын
You Nailed it 🔥 as always.
@Chani003
@Chani003 4 жыл бұрын
Waiting for this
@himanshusoni8096
@himanshusoni8096 4 жыл бұрын
Hi Naveen, Thanks for putting your efforts and sharing videos related to automation testing. I would like to request you to please make a video or share a document related to programming interview questions for testers. Level of programming interview questions are high. Data structure and algorithm questions are being asked in interview from QA automation engineer in many good companies. How to get prepared for the same?
@benitshetty8492
@benitshetty8492 3 жыл бұрын
Awesome Man!....
@lakshayahuja1923
@lakshayahuja1923 4 жыл бұрын
This video is amazing for what i was looking for i am able to read content from gmail but if there is any attachment in mail then it's throwing an error otherwise its working fine
@avnishexplorer7214
@avnishexplorer7214 4 жыл бұрын
Hey naveen, we should also add to use of gmail rest apis using rest assured to perform send email, get email, reply and so on. I think that will be very helpful for all. I have done it at my end.
@arvindsah3273
@arvindsah3273 4 жыл бұрын
you can share the repo link it might help others. Happy Learning.
@MathanKumar-tg1jc
@MathanKumar-tg1jc 4 жыл бұрын
Can you share repo link @Avnish Explorer
@avnishexplorer7214
@avnishexplorer7214 4 жыл бұрын
I have not push yet, surely I will do that and share the link soon so that everyone can get.
@niladrisen3614
@niladrisen3614 2 жыл бұрын
Please share the repo link
@kishorekumar5376
@kishorekumar5376 4 жыл бұрын
Hi Naveen, The above explanation is great!.. I want information about using the OAuth 2.0 with OpenID auth server!
@tusharrana2129
@tusharrana2129 3 жыл бұрын
Thanks Naveen, incredible!!! But can we follow same path for web server applications instead of desktop applications?
@ravimahobia2463
@ravimahobia2463 3 жыл бұрын
Hello Sir Thank you so much for sharing this knowledge, Sir actually I am not able to get OTP related mails or which sent by other party but when I try to send mail itself and try to get it I am able to fetch the result in this scenario but for other emails "not found message" getting display, please suggest the solution.
@testmail4278
@testmail4278 4 жыл бұрын
Hello Naveen Sir, Can you please help in doing the same in Selenium with C# too. Would be very helpful Sir.
@komalilimmu7720
@komalilimmu7720 3 жыл бұрын
Hi Naveen, this video really helped me, small query if image is present in the email body then how can we get the email content??
@mrsdet
@mrsdet 2 жыл бұрын
Hi Naveen, Thanks a lot... Its working fine but when I triggered a simple text email by using Apache commons email then its not working. Can you please help me out.
@anagamt1692
@anagamt1692 Жыл бұрын
Hi Naveen. This video is really helpful. I have query though. How to fetch messages which are lengthy and having text on images? I am trying this kind of text reading and it is only rendering half of the message. In such scenario how to handle messages. I tried parts and mime/text conversion. Still only half of the message is read.
@swethaswty3562
@swethaswty3562 3 жыл бұрын
Is there a way to read mime multipart/mixed email. I have searched for soultion but couldn't find one. When ever I try read such email it returns me complete raw HTML code
@teamautomation1t7
@teamautomation1t7 4 жыл бұрын
Hi naveen, if email subject contains hi - this- is- my- test- mail . it is throwing exception. Please comment on that
@saikiransikhakolli6860
@saikiransikhakolli6860 3 жыл бұрын
hi Naveen first of all congrats for your achievement. I got a problem when the subject having spaces for example: "OTP for Guest" code is not able to read the subject please let us know the solution for this...Thank you
@abuzarawan
@abuzarawan Жыл бұрын
Hey Naveen, thank you for this amazing video. Can you please let me know how can we fetch an Email from other user? Right now, this only fetch the Emails being send out by the self account
@sankaranarayanan5700
@sankaranarayanan5700 3 жыл бұрын
@Naveen, Can you please let us know how to fetch subject and body using outlook APIs
@shankrukulkarni3234
@shankrukulkarni3234 Жыл бұрын
is it possible to fetch the attachements from mail and load it to the gcp storage
@savithaudayasankar4748
@savithaudayasankar4748 2 жыл бұрын
Thanks for ur video. I have followed the instructions and I am getting below error: Illegal base64 character 2d. I am trying to read the email with Images in the email body. Could you please help me to resolve the issue?
@salibhaldar6568
@salibhaldar6568 2 жыл бұрын
Do we have to hardcode the subject? if two subject is same, how to read both of them?
@foodmatter
@foodmatter 3 жыл бұрын
Hi sir, I have tried this flow to send email. It is working in local but when I have deployed the code servers, It's not working. Do you have source which is working in web.
@richadubey5939
@richadubey5939 4 жыл бұрын
Hey Naveen , Thanks for sharing knowledge it's so helpful for us I have started with selenium using python scripting and I am enjoying it I have to get content from webpage and send it using outlook or gmail can u tell me I have successfully get content from web page not sure how to paste it to outlook or gmail can u pls help or how I can paste it ms word ?
@hz2185
@hz2185 3 жыл бұрын
Hey, I am facing an issue if subject name has special character then it failed to find email subject for example kit - Reset Password
@ankitpatel1769
@ankitpatel1769 3 жыл бұрын
Hi Sir, 1.In case of simple text email it is working, but when we are getting some html template in email, then this is not working(like in case of reset password where we got some button of reset password), although I am using python to do this. 2.Mail count is not correct incase of sending mail in same mail thread. can you please provide some way around for the above issues. by the way thanks for four regular support, learned a lot from your videos.
@samratdagde3349
@samratdagde3349 Жыл бұрын
Hi Naveen thanks for the video but facing some problem and getting an exception is ( because you are running on a non posix file system) i don't understand where i am making mistake.. can you please help me with this
@niladrisen3614
@niladrisen3614 2 жыл бұрын
How to create a REST email service using that configuration? Please help
@pravinkumarelumalai3335
@pravinkumarelumalai3335 3 жыл бұрын
Hi Naveen, thanks for your videos...can u help me with method for reading otp from gmail using API.
@ArunkumarN-sh2zr
@ArunkumarN-sh2zr 3 ай бұрын
Hi Naveen sir, In body if there is any different format of test or images it is throwing error do u have code for fetching the body in console if it has images or special type of texts
@erprasannarayabagi
@erprasannarayabagi 9 ай бұрын
00:08 The video explains how to fetch Gmail subject and body using Gmail APIs. 08:58 Learn how to fetch Gmail subject and body using Gmail APIs. 15:48 Authorize access to Gmail APIs and fetch subject and body 20:21 The video discusses how to fetch Gmail Subject & Body using Gmail APIs 24:15 The video discusses fetching Gmail subject & body using Gmail APIs. 29:31 Fetch Gmail subject and body using Gmail APIs 33:34 Learn how to fetch Gmail subject and body using Gmail APIs. 37:52 How to fetch Gmail Subject & Body using Gmail APIs
@amazingclubs5349
@amazingclubs5349 Жыл бұрын
Hi Naveen !! If the mail is coming from out source, how we can fetch that ? , this is that process when we are itself sending the mail, how if the mail is coming from Project system.
@rajeshbhagatt
@rajeshbhagatt 3 жыл бұрын
Can you please make video on how to verify outlook emails by selenium
@rajatgoyal303
@rajatgoyal303 2 жыл бұрын
Hey Naveen , I want to ask how can we get the file an email contains ? for exmample If an email contains a .csv file how can we read or download it ?
@Mridubandari
@Mridubandari Жыл бұрын
Hi Naveen, could you please let us know how can we extract the images from email body. Ex. Email body has and img tag is in the . How can we handle this to extract imgs, please help, thank you 🙏
@HarishS-ic5xe
@HarishS-ic5xe 7 ай бұрын
Hi Naveen, How to read mail which is of the HTML format like for example the airtel which sends offers& discounts email which is of HTML format.
@manish89arya
@manish89arya 3 жыл бұрын
@Naveen I am getting error in this import statement import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver; due to which not able to recognoze LocalServerReceiver class.. could u pls assist
@mihirpatil5723
@mihirpatil5723 Жыл бұрын
any new work around after google policy changes
@Jayakrishna-ly3ei
@Jayakrishna-ly3ei 2 жыл бұрын
Hi sir, Is there another video for cypress ? i have this scenario where user after writing email address, he click on submit button, after submitting it will send an email with a link to the user email, so user should click on that link in order to make his sign in successful, i want to know how to perform that in cypress, if there is a video already for that, pls share the video link..........
@nandinidyawarkonda5505
@nandinidyawarkonda5505 3 жыл бұрын
Hi Naveen, i am not able to read the mail with subject "0BZo0000000KyjG Sandbox: Your Developer Edition Login Information" . Where as , I am able to read the other mails. Could you please suggest what might be issue . And why its not reading the mail even though we have mail with subject in inbox
@vandanam288
@vandanam288 4 жыл бұрын
Hey Naveen, Will u teach python and python automation???
@nanniakki334
@nanniakki334 Жыл бұрын
Hello, I am using gmail service in my angular application, but i am unable to read and display attachments on UI, how can i do??
@miscellaneous5523
@miscellaneous5523 2 жыл бұрын
how to do this behind corporate proxy?
@shaikmasthan833
@shaikmasthan833 4 жыл бұрын
Hi Naveen, thanks for the tutorial bro. I have successfully enabled the Gmail API and able to read the emails from the Gmail using Gmail API. But today i have changed my google password. Now it is throwing the exception called 'Token has been expired or revoked.' . How can i re - authenticate my gmail account. Kindly help me with this issue.
@nealbangia147
@nealbangia147 3 жыл бұрын
@naveen sir please create one video how do we test this scenario Login by email and password then once OTP verified which received from either phone or email then only login will work and show as toast message login is successful.
@vivekauti7703
@vivekauti7703 3 жыл бұрын
how can i download attachement using this
@user-wi5qy1fu3l
@user-wi5qy1fu3l Жыл бұрын
i want to use gmail api in react native mobile app, if you have any solution tell me
@user-cz8dw6zo6h
@user-cz8dw6zo6h Жыл бұрын
how to download an attachment?
@prashanthdasmapur6872
@prashanthdasmapur6872 Жыл бұрын
Hii sir, It is possible in cypress?, if possible means please make video on cypress to read gmail messages
@sree8004
@sree8004 3 жыл бұрын
hi naveen,Exception in thread "main" java.lang.NoClassDefFoundError: org/mortbay/jetty/Handler at com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver$Builder.build( stuck with this error )
@ankursharma1128
@ankursharma1128 2 жыл бұрын
Hi Sir, I am not able to get the mails with attachments using this code. Please help
@eric000
@eric000 4 жыл бұрын
I use php imap library for this.
@netersingh4452
@netersingh4452 3 жыл бұрын
@Naveen. is this free service by google. and what will happen if somebody else run our code do he has to again go through authentication process.
@somanathgaikwad2221
@somanathgaikwad2221 3 жыл бұрын
Hey, Naveen I am getting this exception, Please help me with this. "Exception in thread "main" java.lang.RuntimeException: java.lang.IllegalArgumentException: Illegal base64 character 2d"
@prathu25M
@prathu25M 3 жыл бұрын
i want call api from server where i cant click on allow
@testproduct-zj8vf
@testproduct-zj8vf Жыл бұрын
Need 2022 update on this API please. Many things have changed in google console. little bit confused on how to do this.
@morfioss3974
@morfioss3974 2 жыл бұрын
can you do a tutorial for springboot on how to send email
@springseason5774
@springseason5774 5 ай бұрын
Could you please put one video for how to overcome "Couldn't sign you in" error while login Gmail UI via selenium Java. Getting error like "This browser or app may not be secure" how to resolve this issue - could you please create video for latest issues
@My_ButtaBomma
@My_ButtaBomma 4 жыл бұрын
#Naveen, I am woundering that your Eclipse is not hanging of overloaded code?
@naveenautomationlabs
@naveenautomationlabs 4 жыл бұрын
You can close unused projects in ur eclipse to make it light. :)
@rawanali8677
@rawanali8677 4 жыл бұрын
please do it with PHP
@angelzajia
@angelzajia 4 жыл бұрын
this only work from command line... :(
@rupamrouth9859
@rupamrouth9859 3 жыл бұрын
An amazing tutorial. Just want to notify if there's an attachment in mail, then exception comes on this line - String body = new String(Base64.getDecoder().decode(jp.getString("payload.parts[0].body.data"))); How to overcome this issue. Can we add one thing whether attachment is available or not through this api?
@vivekauti7703
@vivekauti7703 3 жыл бұрын
hi, did you find any solution im also stuck at this
@Jagson_13
@Jagson_13 Жыл бұрын
Hi, Did you get any solution on Email having attachments? and can we count the number attachments in email? Thank you.
@amazingclubs5349
@amazingclubs5349 Жыл бұрын
@@Jagson_13 , can you help me , If the mail is coming from out source, how we can fetch that ? , this is that process when we are itself sending the mail, how if the mail is coming from Project system.
@Jagson_13
@Jagson_13 Жыл бұрын
@@amazingclubs5349 Sorry I haven't yet tried the fetching data from email. I'm looking for solution to send multiple emails with attachment at the same time as a part of load testing. Please let me know if you have any idea on the same.
@hz2185
@hz2185 3 жыл бұрын
unable to set permissions for C:\Users\hirac\GmailControl\src\main esources\credentials, because you are running on a non-POSIX file system. email not found.... Please guide me how can resolve this issue
@swapnilpundir461
@swapnilpundir461 2 жыл бұрын
How did you solve this?
@nandinin6614
@nandinin6614 3 жыл бұрын
I am getting the error as below Naveen , 1. Exception in thread "main" java.lang.RuntimeException: java.lang.IllegalArgumentException: Cannot invoke method getAt() on null object .
@suriesiva
@suriesiva 2 жыл бұрын
did anyone face this type of errors above to find solution , Please share in link
@shaikmasthan833
@shaikmasthan833 4 жыл бұрын
Hi Naveen, Can i access the gmail and access the messages even my 2 step verification is turned on ?
@arvindsah3273
@arvindsah3273 4 жыл бұрын
I think you should give a try, I guess it should.
@MathanKumar-tg1jc
@MathanKumar-tg1jc 4 жыл бұрын
Can we do this for a specific domain. Like @mycompany.com?
@arvindsah3273
@arvindsah3273 4 жыл бұрын
No, there api's are provided by gmail so you can only access gmail accounts.
@MathanKumar-tg1jc
@MathanKumar-tg1jc 4 жыл бұрын
I am trying to access my organisation email to read mails and use it for my automation My mail server is hosted under gmail only domain name is changed eg instead of abc@gmail.com it is abc@mycompany.com And i followed all steps as mentioned in video, i am getting NPException when trying to read email 2 out of 10times. Due to which i am struggling to read the mails
@karthikyadav8185
@karthikyadav8185 3 жыл бұрын
@@MathanKumar-tg1jc does it worked? Did you got any solution for this?
@vaibhavsh1098
@vaibhavsh1098 4 жыл бұрын
Hi Naveen, I found this interesting but when I tried the same I am getting 403 permission denied message. Any idea what could be missing here? I enabled the GMail API and used the same Credentials.json file. It says "Unable to set permissions, because you are running on a non-POSIX file system" . Any idea how I can get it fixed?
@ammarkhan1629
@ammarkhan1629 3 жыл бұрын
I was facing the same issue. You can try below steps: (1) Delete the tokens folder from your directory. (2) Keep your credentials.json in your root directory and inside /src/test/resources. (3) There should be a variable 'SCOPES', if the default scope is label change it to 'MAIL_GOOGLE_COM', something like-> private static final List SCOPES = Collections.singletonList(GmailScopes.MAIL_GOOGLE_COM); (4) When you execute your script, this should ask you to allow permissions to read,send,delete, etc. Click on allow. This should work.
@deepanshutyagi6157
@deepanshutyagi6157 Жыл бұрын
Did you find the solution ?? I am also facing same issue
@arjuarju456
@arjuarju456 Жыл бұрын
Bro disable anti virus
@billivin01
@billivin01 3 жыл бұрын
Dangerous words... "sometimes it doesn't work" and "From my side I have enabled it, let enable it again" (something that was not even enabled in the first place)
@srinivasak4087
@srinivasak4087 4 жыл бұрын
Hi Naveen , i followed all the steps , now i am able to read the mail , but when i tried to read a mail body which has pictures and company logo, in this case i am not able to read mail body , getting below issue .Exception in thread "main" java.lang.RuntimeException: java.lang.IllegalArgumentException: Cannot invoke method getAt() on null object at GMail.getGmailData(GMail.java:137)
@prafulkolhe7151
@prafulkolhe7151 3 жыл бұрын
Same here. Got a fix for that ?
@prafulkolhe7151
@prafulkolhe7151 3 жыл бұрын
Tried debugging a bit and found that my email which is sent via the application does not have multiparts from the line payload.parts[0].body.data which i thought was causing the issue. But when changing this to payload.body.data which is with respect to the received json it gives Exception in thread "main" java.lang.RuntimeException: java.lang.IllegalArgumentException: Illegal base64 character 2d at com.qa.comcate.GmailAPiLib.GMail.getGmailData(GMail.java:138) at com.qa.comcate.GmailAPiLib.GMail.main(GMail.java:208)
@suriesiva
@suriesiva 2 жыл бұрын
@@prafulkolhe7151 Did you got any break through
@sivamarvel
@sivamarvel 3 жыл бұрын
Illegal base64 character 5f i am getting this error
@nirdamari1402
@nirdamari1402 2 жыл бұрын
Same, Maybe the decoder is fucked?
@sangeethaganesan9981
@sangeethaganesan9981 6 ай бұрын
video clarity is not there .
@aniruddhapssinghgehlot5471
@aniruddhapssinghgehlot5471 10 ай бұрын
VGA Sir, Your code is working now. Thank you so much! But one issue - I am able to read emails that i sent personally with subjects as "test" but system generated emails subjects are not read ! error in eclipse console - Exception in thread "main" java.lang.RuntimeException: java.lang.IllegalArgumentException: Illegal base64 character 2d
@aniruddhapssinghgehlot5471
@aniruddhapssinghgehlot5471 10 ай бұрын
Please advise Sir. Thanks in advance
@romaverma1282
@romaverma1282 5 ай бұрын
HI Naveen,Thanks fro the wonderful tutorial Just One issue I'm getting that I ran the Code getting error of "com.google.api.client.util.store.FileDataStoreFactory setPermissionsToOwnerOnly WARNING: unable to change permissions for everybody" & "com.google.api.client.util.store.FileDataStoreFactory setPermissionsToOwnerOnly WARNING: unable to change permissions for owner" Can you assist on that?
@dineshumapathykumar
@dineshumapathykumar 4 ай бұрын
@romaverma1282 Did you get any solution for the issue?I also get the same problem.Kindly let me know,thanks!
@ArunkumarN-sh2zr
@ArunkumarN-sh2zr 3 ай бұрын
Hi Naveen sir, In body if there is any different format of test or images it is throwing error do u have code for fetching the body in console if it has images or special type of texts
What is OAuth2? How does OAuth2 work? | Naveen AutomationLabs
19:56
Naveen AutomationLabs
Рет қаралды 68 М.
How to send email using Gmail API (uses OAuth2 and nodemailer)
17:55
Pleased the disabled person! #shorts
00:43
Dimon Markov
Рет қаралды 32 МЛН
WORLD'S SHORTEST WOMAN
00:58
Stokes Twins
Рет қаралды 130 МЛН
REST API concepts and examples
8:53
WebConcepts
Рет қаралды 6 МЛН
ASMR Programming - Animated Login Page - No Talking
18:18
AsmrProg
Рет қаралды 1,5 МЛН
How to automate OTP number in Selenium and API || Using Twilio SMS APIs
38:43
Naveen AutomationLabs
Рет қаралды 73 М.
AMT2 - Extracting Emails from your Gmail Inbox using python
16:02
DigitalSreeni
Рет қаралды 33 М.
Progressive Web Apps in 2024
4:07
Awesome
Рет қаралды 39 М.
Klavye İle Trafik Işığını Yönetmek #shorts
0:18
Osman Kabadayı
Рет қаралды 9 МЛН
Tag him😳💕 #miniphone #iphone #samsung #smartphone #fy
0:11
Pockify™
Рет қаралды 4,7 МЛН