Tag: gmail

尝试使用node.js导入Gmail联系人

我正在尝试导入Gmail联系人。 我已经成功地获得了access_token,但是当试图让联系人浏览器不断抛出错误。 invalid_grant 我的代码如下。 用于validation和callback。 authorize: function(req, res){ var CLIENT_ID = '927112080821-vhsphqc79tb5ohfgpuvrp8uhh357mhad.apps.googleusercontent.com'; var CLIENT_SECRET = 'gdgofL0RfAXX0in5JEiQiPW8'; var SCOPE = 'https://www.google.com/m8/feeds'; oa = new oauth.OAuth2(CLIENT_ID, CLIENT_SECRET, "https://accounts.google.com/o", "/oauth2/auth", "/oauth2/token"); res.redirect(oa.getAuthorizeUrl({scope:SCOPE, response_type:'code', redirect_uri:'http://localhost:1234/callback'})); }, callback: function(req, res){ console.log(req.query.code); oa.getOAuthAccessToken(req.query.code, {grant_type:'authorization_code', redirect_uri:'http://localhost:1234/callback'}, function(err, access_token, refresh_token) { if (err) { res.end('error: ' + JSON.stringify(err)); } else { getContactsFromGoogleApi(access_token); //res.write('access […]

从Gmail API获取电子邮件的直接链接(列表消息)

我正在从Node.JS的Google Gmail API中检索邮件,但是在生成或检索到电子邮件的直接链接时遇到问题。 目前,我正在使用下面的代码: var link = 'https://mail.google.com/mail/u/0/#inbox/' + messageContent.threadId; 但是,正如你所看到的,它总是导航到用户的主收件箱( /u/0/ )。 我试图链接的电子邮件位于我的第二个和第三个收件箱中。 我尝试使用get消息调用获取电子邮件的收件箱号码,但不幸的是,它不返回该数据。 我也尝试了下面这段代码,但它也没有工作。 它只是加载我的主要收件箱。 var link = 'https://mail.google.com/mail/#inbox/' + messageContent.threadId; 有谁知道如何生成正确和直接的电子邮件链接? 提前致谢。 testing用例 首先,loginGoogle的两个或更多帐户。 正如您在下面的图片中看到的,我已login到3个帐户。 第一个(顶部)是我的主要帐户。 其他的是二级账户。 直接链接到我的主要Gmail是: https : //mail.google.com/mail / u / 0 / #收件箱/ 直接链接到我的第二个帐户是: https : //mail.google.com/mail / u / 1 / #inbox / 我的第三个和最后一个帐户的链接是: https : //mail.google.com/mail […]

在javascript / node.js中连接到Gmail IMAP API

我试图通过IMAP API连接到Gmail。 我正在使用Bruno Morency的node-imap库 。 为了创buildoauth_signature,时间戳和随机数,我使用另一个库 。 更具体地说:资源所有者已经authentication了消费者。 所以我有一个访问令牌+秘密。 当然,我也有消费者的秘密+标志。 所以我想要的是使用这里描述的XOAuth机制(标题:SASL初始客户端请求)login。 当执行代码时,我得到一个错误: Error while executing request: Invalid credentials d43if2188869web.36 我不知道我做错了什么。 其实可能有更多的原因。 错误的base64编码(虽然编码可能正常工作,因为你得到不同的编码不同的错误,我很确定这不是),错误的签名计算(更新:我现在用http://oauth.net/core/ 1.0a /#sig_base_example ),nonce计算或其他。 我可以在Java应用程序中使用相同的凭据(消费者+资源所有者)进行身份validation,所以凭据很可能不是错误的原因(只是错误的编码/签名计算) 最后的代码。 我省略了消费者的钥匙+秘密,因为显而易见的原因,既没有给所有人的标志+秘密也没有。 var oauth_version = "1.0"; var oauth_timestamp = OAuth.timestamp(); var oauth_nonce = OAuth.nonce(6); //random nonce? var oauth_consumer_key = "NOTFORYOU"; //validated var oauth_consumer_secret = "NOTFORYOU"; //validated var oauth_token = […]

node.js nodemailer gmail错误

我试图发送一个电子邮件使用node.js – nodemailer模块,我的整个代码看起来像 var http=require("http"); var nodemailer=require("nodemailer"); http.createServer(function(req,res){ res.writeHead(200, {"Content-Type": "text/plain"}); var transporter = nodemailer.createTransport('SMTP',{ service: 'gmail', auth: { user: 'myemail@gmail.com', // my mail pass: 'mypassword' } }); var mailOptions = { from: 'Fred Foo ✔ <foo@blurdybloop.com>', // sender address to: 'myemail@gmail.com', // the same mail = want to send it to myself subject: 'Hello […]

Google Cloud Pub / Sub API – 推送电子邮件

我使用node.js创build一个应用程序,每次收到电子邮件时都会从Gmail获取PUSH,然后根据CRM中的第三方数据库检查该应用程序,并在该CRM中包含电子邮件时在CRM中创build一个新字段。 我无法使用Google新的Cloud Pub / Sub,这似乎是在没有持续轮询的情况下从Gmail推送的唯一方法。 我已经通过这里的说明: https : //cloud.google.com/pubsub/prereqs,但我不明白这是应该如何从我的桌面上的应用程序工作。 看起来pub / sub可以连接到一个已validation的域,但是我不能直接连接到我的电脑上的.js脚本。 我已经保存在一个JSON文件的API密钥,并使用以下内容: var gcloud = require('gcloud'); var pubsub; // From Google Compute Engine: pubsub = gcloud.pubsub({ projectId: 'my-project', }); // Or from elsewhere: pubsub = gcloud.pubsub({ projectId: 'my-project', keyFilename: '/path/to/keyfile.json' }); // Create a new topic. pubsub.createTopic('my-new-topic', function(err, topic) {}); // Reference an existing […]

Nodemailer / Gmail – 什么是一个刷新令牌,我如何得到一个?

我正在尝试使用nodemailer在节点应用程序中做一个简单的联系表单。 我希望所有的味精都能从我为此目的而创build的Gmail帐户发送到我的个人邮件。 在客户端,我所做的只是获取客户的名称/邮件/消息并将其发送到服务器。 它在本地正常工作,但部署时失效(在heroku btw)。 经过快速search,似乎我必须从谷歌开发者控制台生成一个ClientId和ClientSecret – 我做了 – 但是当涉及到生成一个“刷新令牌”,我完全失去了。 var smtpTransport = nodemailer.createTransport("SMTP",{ service:"Gmail", auth:{ XOAuth2: { user:"myaccount@gmail.com", clientId:"", clientSecret:"", refreshToken:"" } } }); 我很困惑 :什么是一个刷新令牌,我怎么得到一个?