AndroidPub
Published in

AndroidPub

Firebase Functions: Send Email using Google OAuth2

firebase functions: send mail using Gmail

1. Create a new project in the Google Developer Console

Click on Select a project in Google Developer Console
Click on “NEW PROJECT” to create a new project
Create a new project

2. Setup API Credentials for OAuth2

Select API’s & Services and then Credentials
Create credentials for out project
Create OAuth client ID screen
OAuth consent screen
Creating OAuth client ID

3. Configure OAuth2 for our App

  • Go to this link https://developers.google.com/oauthplayground and click on the “settings icon” from the top right corner as shown in the image below.
  • Check the box saying “ Use your own OAuth credentials” and enter the “Client ID” & “Client Secret” we received in the last step.
  • Now on the left side menu enter https://mail.google.com/ in the ‘input your own scopes’ textbox or search “Gmail API v1” from the list & select https://mail.google.com/.
  • Press the “Authorize APIs” button.
OAuth 2.0 Playground screen: step 1
Warning screen for the app
OAuth 2.0 Playground screen: step 2

Code part 💻

npm install nodemailer googleapis

--

--

The (retired) Pub(lication) for Android & Tech, focused on Development

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Akshay Bhange

Android Lover, Tech enthusiast, UI/UX♥️, Flutter follower😍, Software Developer.