使用 OAuth2 和 nodemailer 从我的 gmail 帐户发送电子邮件 [英] send emails from MY gmail account with OAuth2 and nodemailer

查看:31
本文介绍了使用 OAuth2 和 nodemailer 从我的 gmail 帐户发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过我自己的服务器从我的 gmail 地址发送电子邮件.我正在使用 nodemailer 并且使用帐户凭据是不稳定的,并且通常不起作用并导致此

但是如何在没有任何浏览器交互的情况下获得访问令牌?

我似乎在这里遗漏了一些微不足道的东西......

我已经浏览了我能找到的关于 OAuth2、令牌和 API 的所有谷歌教程和文档,但所有指南都一次性通过浏览器.

解决方案

转到 OAuth Playground,点击右上角的齿轮,勾选Use your own OAuth credentials并插入你的clientIDclientSecret>.

然后在左侧的列表中选择您想要的 Gmail API v1 范围并按照概述的步骤操作,您将获得一个 access_token 和一个 refresh_token.

I want to send emails from my gmail address through my own server. I'm using nodemailer and using account credentials is flaky, and often times doesn't work and leads to this thread

I've implemented everything on that thread many times, and still it's flaky, and also I know OAuth2 is the way to go.

I have a project with cliendID and clientSecret in google developer console, as you can see:

But how do I get an access token WITHOUT any browser interaction?

I seem to be missing something trivial here ...

I've went through all google tutorials and docs I could find about OAuth2, tokens, and APIs, but all guides go through the browser in one point.

解决方案

Go to the OAuth Playground, click the cog on the top right, check the Use your own OAuth credentials and insert your clientID and clientSecret.

Then select the Gmail API v1 scopes you want in the list to the left and follow the outlined steps and you will get an access_token and a refresh_token.

这篇关于使用 OAuth2 和 nodemailer 从我的 gmail 帐户发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆