# Gmail API 電子郵件服務設計 * [Gmail API 額度](https://support.google.com/a/answer/166852?hl=zh-Hant#zippy=%2C%E5%85%8D%E8%B2%BB%E8%A9%A6%E7%94%A8%E5%B8%B3%E6%88%B6%E9%99%90%E5%88%B6) * [程式碼位置](https://github.com/gonsakon/express-week4-sample/tree/feature/gmailAPI) * 記得錄影 * 中場休息提供線上發表會流程 ## 需拿到 Google Console Gmail 三個資訊 ``` // 專案資料 GOOGLE_AUTH_CLIENTID= GOOGLE_AUTH_CLIENT_SECRET= // Gmail 授權碼 GOOGLE_AUTH_REFRESH_TOKEN= ``` ## Gmail API 申請流程 1. [申請 Google 服務設計,新增一個專案,並申請 Oauth 2.0 ](https://console.cloud.google.com/welcome) 2. 建立 Oauth 憑證,以獲得 `CLIENTID`、`CLIENT_SECRET`,已授權的重新導向 URI 設置為 `https://developers.google.com/oauthplayground` 3. 進入 [Oauth 2.0](https://developers.google.com/oauthplayground) 介面領取 Gmail 憑證,在右上角齒輪填寫 `CLIENTID`、`CLIENT_SECRET`,填寫開通功能為 `https://mail.google.com/` 後執行 4. Gmail 申請授權後,獲得一次性 `Authorization code`,來換取 `Refresh token` ## 安裝 NPM 套件 * [nodemailer](https://nodemailer.com/about/) - 藉由 Node.js 發出一個 SMTP(Simple Mail Transfer Protocol,簡單郵件傳輸協定) 請求 * [googleapis](https://www.npmjs.com/package/googleapis) - **讓你自己的 Gmail 帳號做為 SMTP 伺服器**: 藉由它使用 gmail 服務,讓自己的 gmail 帳號做為 SMTP 伺服器 ## 程式講解 * [程式碼位置](https://github.com/gonsakon/express-week4-sample/tree/feature/gmailAPI) ## 成果發表會與獎學金機制講解
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up