[英]Get refresh token and gmail user profile in node.js using OAuth2
[英]Gmail send email API, Authenticate using OAuth2 without storing the refresh token in the app
我正在從我的 NodeJS 應用程序發送電子郵件,該應用程序運行良好,沒有任何問題(使用 NestJS 框架)。 我遇到的問題是我需要存儲刷新令牌(在我的情況下是在 .env 中)以進行身份驗證,我認為這不是一個好方法。 因為,如果刷新令牌被更新,我的應用程序將中斷,我每次都必須手動更新刷新令牌。 是否有任何方法可以獲取調用任何 API 的刷新令牌? 任何幫助表示贊賞。
以下是我正在使用的代碼片段。 我使用nestjs-modules/mailer
,但即使使用nodemailer
,也會出現同樣的問題。
transport: {
service: 'gmail',
secure: false,
auth: {
type: 'OAuth2',
user: process.env.GOOGLE_SENDER_EMAIL,
clientId: process.env.GOOGLE_CLIENT,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
refreshToken: process.env.REFRESH_TOKEN,
},
},
defaults: {
from: '"ABC" <abc@gmail.com>',
},
template: {
dir: join(__dirname, 'emails/templates'),
adapter: new HandlebarsAdapter(),
options: {
strict: true,
},
},
}),
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.