The Gmail API is a RESTful API that can be used to access Gmail mailboxes and send mail. We will use it to send out corresponding emails to our customers.
Create Project.Project Name and click Create.Enable API's and Services.Enable Gmail API.Create Credentials.https://developers.google.com/oauthplayground as a redirect URI in order to generate the refresh and access tokens later.Client ID and your Client Secrete keys.access and refresh tokens, go to https://developers.google.com/oauthplayground. Click on the cog icon in the top right, check Use your own OAuth credentials and enter Client ID and Client Secret.In the left column, select Gmail API v1 and click Authorise APIs
12.If you are signed into multiple accounts, when prompted select the relevant account.
Allow.Exchange authorisation code for tokens. This will give you the refreshToken and the expires token.You should now have all the necessary credentials. Add the following credentials inside the config.env file.
auth is the authentication object.
user โ user email address (required)clientId โ is the registered client id of the applicationclientSecret โ is the registered client secret of the applicationrefreshToken โ is an optional refresh token. If it is provided then Nodemailer tries to generate a new access token if existing one expires or failsaccessToken โ is the access token for the user. Required only if refreshToken is not available and there is no token refresh callback specifiedexpires โ is an optional expiration time for the current accessTokenEMAIL_FROM=
EMAIL_CLIENT_ID=
EMAIL_CLIENT_SECRET=
EMAIL_REFRESH_TOKEN=
EMAIL_ACCESS_TOKEN=
EMAIL_EXPIRES=