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.
Project Nameand click
Enable API's and Services.
https://developers.google.com/oauthplaygroundas a redirect URI in order to generate the refresh and access tokens later.
Client IDand your
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
In the left column, select Gmail API v1 and click
12.If you are signed into multiple accounts, when prompted select the relevant account.
Exchange authorisation code for tokens. This will give you the
You should now have all the necessary credentials. Add the following credentials inside the
auth is the authentication object.
user– user email address (required)
clientId– is the registered client id of the application
clientSecret– is the registered client secret of the application
refreshToken– is an optional refresh token. If it is provided then Nodemailer tries to generate a new access token if existing one expires or fails
accessToken– is the access token for the user. Required only if refreshToken is not available and there is no token refresh callback specified
expires– is an optional expiration time for the current accessToken
EMAIL_FROM= EMAIL_CLIENT_ID= EMAIL_CLIENT_SECRET= EMAIL_REFRESH_TOKEN= EMAIL_ACCESS_TOKEN= EMAIL_EXPIRES=