Gmail-OAuth2.0 Using Postman

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone this is absa ali so in this video we're gonna uh we're gonna access gmail using uh oauth 2.0 so this is actually continuation of my previous videos so if you see already in my channel uh there is a video called google api or 2.0 you get access token and request token uh this is a part one so here i uh i think some people are having some issue uh using a curl command so i'll try to uh continue on the same process in this particular video with uh completely with the postman okay yeah if you guys uh want to see more videos on my channel also you can go to this particular website that i'll be uh i'll be sharing this link in the video descriptions of this current video alright so you can also see what all uh a video is specific to this gmail api is available and i'll be adding a lot more videos on this so please subscribe to my channel right okay first of all let's go to the google and if you do not have any uh gmail uh gmail account just create one uh new account and then you need to go to uh developer this is theconsole.cloud.google.com okay so just go to this particular website right once you are there just select i have a couple of account over here so i'll be selecting my preferred gmail account once you select that what you need to do is you need to create a project over here so i already have some project that's why it's showing over here if you do not have project then just need to create a project okay so just click on a new project right maybe i'll say my demo project to right so i'll be uh you you can name anything click on create so it will take some time to create your project right once that is being done you can see select project you can also click over here or maybe from this drop-down also you can select the project right that is being selected already then after that what you need to do is um you can also go over here in the search you can also search for gmail okay so in here you'll see gmail api just click on the gmail api okay so you need to enable the gmail api for that particular account or for that particular project i would say all right so this is done okay so once that is being done uh enable then create credential click on that then here you need to select particular things uh okay so here you need to select gmail api okay here you need to say user data because you are creating oauth client so you need to select this particular thing if you do not want to accept any users informations or users consent then you don't have to select this one this one uh you need to select this one this this particular will use the service account okay but we need a oauth 2 application so app name uh you can um give any name gmail api app okay so user support email just select the email name if you have any logo you can select that and developer information you can say i can say my same email address over here save and continue so here you need to also select add or remove scopes you can also um go ahead with the gmail um gmail here you can see different different uh scopes available okay so i would say the gmail scopes this is the read delete all your email or this thing i'll be selecting this one all right so let me see that once again i select this one and it is update over here okay so you should see uh in here already fine then save and continue then the scopes uh over here i'll select the web application and let's you can name anything over here for me let it be then add url i will say http uh you can provide your own [Music] production ready uh host name or url over here okay where you want to redirect from here okay creating now uh then you can download the credential so what i'll do client id i'll just copy from here and i would copy from here and write it over here and also i can download this for my difference in the vector and uh uh most important thing you need to also go to this what concerning screen okay uh here this is in testing and the application is in a testing phase okay so you need to add the test user because if you publish this this will be this will be in production and you also need to provide or maybe this application will be reviewed by the google then only once that is review process is being done then they will activate uh your account or your app okay um as we are not going to deploy in the production or this so let it be there and i can just add some users over here so i can use the same um same user like this i would use my the same email id over here okay save also i can use my another email id all right so these two will be saved over here right so this this two are the testing accounts basically you can send delete or do whatever using this two accounts okay you can use this app testing app okay because it is not in production so if you publish then it will take some time from the google then they will activate this app then only you will be able to access everything but for now uh we can add this to uh most importantly the same gmail uh gmail id i'm using over here and one more fine so once that is being done uh you can go ahead and go to the domain um yeah no need uh agreement is no need i think that's all so once that is being done um yeah uh you need so uh we got the client id so client secret uh you can get it from the uh the file that you downloaded already so in my desktop i can go over here and i can just open it in any text editor all right so you can see the client secret is there and client id is the also is there so i just copy the client secret if you can see my screen okay so let me just quickly copy from here this is my client secret and i'll just put it over here okay so this is my client a secret so this two step is being done now the next uh things are three steps we need to perform the first one is to generate the code then the second one is the request token third one is get the access token okay so this three thing we can do um easily using postman so for that you need need to download the json file okay so i already uploaded in my github repository so i'll be providing this link in description okay so you can just download this particular collection okay collections.jsons postman collection basically so once you download or maybe you can just copy from copy everything all right and just save it as json file once you save as a json file in somewhere in a local directory then you need to go to uh you need to go to the postman all right so i open the postman okay so make sure you use the postman application another web version okay so you can see over here the import button so just click on that import button right and i choose the file that i already downloaded over here in the desktop i have this gmail authentication collection dot json file so just open here and import it so once you import it and you will see this gmail authentication folder okay so yeah the three things you will be seeing over here okay first one is get code okay so the first is a get a code this this api gate api all right so if you see here uh params within the params uh we are providing access type redirect uri response type and client id so this client id you need to provide from here okay we already got the client id from here i just select the client id all right so once you've got this and you can send it so basically it will try to redirect uh somewhere so what you need to do just copy from here right for the first one and just paste those thing for the code this one right so you just need to paste over here and it will ask you to choose the account so just select your preferred account where we have provided in the test account okay so this one i'll be selecting then uh okay so i you need to authenticate it once you authenticate that um okay i need to 932650 my this is the otp i got so once once that has been done you're saying you have been given access to an app that's currently being tested so as i said so this app is being tested basically uh it is not in the production yet so we are good to go just click on continue okay so here you need to provide that access so this particular app can read compose send and permanently delete all your email from the gmail so you need to click on this check box then continue okay so once the you click on the continue then you will be redirected to this local host then code all right so just copy everything the response from uh ever and just paste it over here and you'll get that this is called the code okay so this is the response type so we can just um paste over here you got the code all right you got the code so then the next step is uh get the refresh token so in the next uh post api call okay this is the post api call go to the body okay so this body make sure this is uh x w form url encoded and you need to use that code here okay just now we got this code i use this code from here and the spare steeped in here okay then the next is client id so make sure you you need to change the everything all right like client id client secret and the code three things you need to change so this is my client secret okay okay so once that is being done just click on the send okay now you got the access token and you got the refresh token i'll just copy everything the response all the response i got it from the second step all right i'll just paste it over here okay so you got this access token using this access token you can um you can access any gmail api right so you can also see uh this is the expires we have refresh token so this is important uh using this refresh token you can generate access token anytime right so make sure this is the refresh token uh you keep it handy so now the next thing we need to do uh how will generate uh how how will get the access token each time when it expire okay now this is the third uh api okay in that collect collection so similarly uh what you need to do is use this client id okay i'll just change so you just change this uh change everything because this all are old client id and client secret etc all right then the refresh token so the refresh token i got it already from the previous step just change it and now you can say you will get the access token time all right so yeah you can get the access token anytime right so yeah like that fine so let's see you can go uh in the gmail api um documentation there you can see a lot of rest api information over there okay so in this i'll just go ahead and get the messages so this list what it will do it will list down all the uh email okay or the messages of that particular user okay so what i'll do i'll just copy this http request that is the get type is it till here so here is user id also you can provide your user id or you can also use me me me also will refer to your current uh gmail id all right so i'll just copy here and i'll just create a new postman uh request called get emails okay i'll just paste the same thing you can see in in place of user id i'll just use me all right so yeah and here i'll select the bearer token all right and and here yeah that's all so in the token you need to use the access token you got from here okay one one more time i just get a new uh refreshed access token using the refresh token once you do that you just paste over here okay once you paste and just click on send so you can see now you got all the sms sorry message the email id and thread id okay so yeah basically using the thread id uh you can then next uh you know access other um other end points to get get the email body or whatever right so yeah you can do like this stuff maybe in the upcoming videos i'll be uh doing more more of the things uh from here uh using the rest api using the postman okay yeah that's all uh for this video bye for now
Info
Channel: OpenSourceAutomation - Afsar Ali
Views: 16,127
Rating: undefined out of 5
Keywords: Google api, gmail, gmail api, gdrive api, gmail oauth2.0, send email using gmail api, gmail automation, gmail with javascript, gmail api using postman, gmail rest api
Id: 8RaSbyk-DJY
Channel Id: undefined
Length: 19min 38sec (1178 seconds)
Published: Wed Sep 22 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.