Tag: Gmail中的API

Node.js向Gmail API发送消息的POST请求

我正尝试使用服务器端node.js向Gmail Send Message API发送请求,但没有成功。 我收到以下错误: body: '{ "error": { "errors": [ { "domain": "global", "reason": "invalidArgument", "message": "\'raw\' RFC822 payload message string or uploading message via /upload/ URL required" } ], "code": 400, "message": "\'raw\' RFC822 payload message string or uploading message via /upload/ URL required" } }' } oauth2token和raw的input参数是有效的,事实上,如果我使用Google OAuth 2操场( https://developers.google.com/oauthplayground )并使用令牌和raw作为电子邮件发送的值。 有人可以看到我错过了什么吗? […]

passport-google-oauth2获取节点js中的gmail.users.messages.list

首先,我对护照节点js + oauth2比较陌生,所以如果您有任何困惑,请发表评论。 我已经尝试下面的身份validation谷歌从oauth2与node.js,这里是代码 var GoogleStrategy = require('passport-google-oauth').OAuth2Strategy; var google = require('googleapis'); var GOOGLE_CLIENT_ID = "—MY-CLIENT-ID"; var GOOGLE_CLIENT_SECRET = "—MY-CLIENT-SECRET"; var app = express(); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: true })); app.get('/', function(req, res){ res.render('index', { user: req.user }); }); app.get('/account', ensureAuthenticated, function(req, res){ res.render('account', { user: req.user }); }); app.get('/login', function(req, res){ res.render('login', { user: req.user […]

是否有可能添加一个端口在其中的pushEndpoint?

我正在尝试在Google的PubSub( https://cloud.google.com/pubsub/ )中尝试添加pushEndpoint,以便我能够接收来自Gmail的推送更新。 我试图添加的pushEndpoint是一个带有端口的HTTPS-URL(例如: https : //developers.example.com :9081/pushEndpoint),但我一直得到Invalid push endpoint given (endpoint=https://developers.briteback.com:9081/mailSyncHandler). Refer to https://cloud.google.com/pubsub/subscriber#create for more information. Invalid push endpoint given (endpoint=https://developers.briteback.com:9081/mailSyncHandler). Refer to https://cloud.google.com/pubsub/subscriber#create for more information. 所以问题是如果有可能添加一个端口到pushEndpoint? 以下是试图创build订阅的代码: var rp = require('request-promise'); rp({ url: 'https://pubsub.googleapis.com/v1/projects/projectId/subscriptions/mailSync', method: 'PUT', headers: { Authorization: 'Bearer accessToken' }, json: { topic: 'projects/projectId/topics/mailSync', pushConfig: { pushEndpoint: 'https://developers.example.com:9081/mailSyncHandler' } […]

我怎样才能得到一个特定的人发送的电子邮件列表?

我正在使用Google Gmail API来获取消息列表。 我想要做的是获得从特定用户发送的所有消息的列表。 这是我到目前为止: var oauth2Client = new OAuth2('', '', ''); oauth2Client.setCredentials(token); var gmail = google.gmail('v1'); gmail.users.messages.list({ auth: oauth2Client, userId: 'me' }, function(err, response) { if (err) { console.log('The API returned an error: ' + err); cb(null, false); } else { cb(null, response); } }); 我试着设置userId: 'person@email.com'但是这给了我以下错误: The API returned an error: Error: Delegation […]

gmail发送api失败,错误代码为400meteor

我想在我的meteor应用程序中使用gmail api发送邮件, Error in calendar insert: Error: failed [400] { "error": { "errors": [ { "domain": "global", "reason": "invalidArgument", "message": "'raw' RFC822 payload message string or uploading message via /upload/* URL required" } ], "code": 400, "message": "'raw' RFC822 payload message string or uploading message via /upload/* URL required" } } 我试了下面, "sendGmail": function(str) { […]

撤销对应用Gmail API的访问权限

我怎么能撤销从后台Node.js访问应用程序因为我们可以select使用方法refreshaccesstoken()生成access_token。 那么有没有类似的方法,我可以用来撤销应用程序的访问。

从id_token Gmail OAuth获取电子邮件

我有一个JSON对象具有以下细节: { access_token: 'access_token', token_type: 'Bearer', expires_in: 3599, id_token: 'longstring' } 使用NodeJs库'googleapis'我怎样才能得到上述响应的电子邮件地址。 我不想使用以下url: https : //www.googleapis.com/oauth2/v1/userinfo?access_token = your_access_token

node.js Gmail API:获取embedded式/embedded式图像

抓取电子邮件时,运行gmail.users.messages.get() ,然后运行以下两个函数来处理payload 。 function getBody(message) { var encodedBody = ''; try{ if(typeof message.parts === 'undefined'){ encodedBody = message.body.data; } else{ encodedBody = getHTMLPart(message.parts); } encodedBody = encodedBody.replace(/-/g, '+').replace(/_/g, '/').replace(/\s/g, ''); } catch(e) {} // there was a failure return decodeURIComponent(escape(window.atob(encodedBody))); } function getHTMLPart(arr) { for(var x = 0; x <= arr.length; x++){ if(typeof arr[x].parts === […]

Google OAuth使用刷新令牌获取新的访问令牌

我试图让我的refresh_token生成一个新的access_token 。 我正在使用请求模块发出请求,但是它返回一个错误,提示“无法find页面”。 var request = require('request'); module.exports = function(callback){ console.log('here'); request('https://googleapis.com/oauth2/v3/token?client_id=NotID&client_secret=Not_Secret&refresh_token=NotRefresh&grant_type=refresh_token', function (error, response, body) { if (!error && response.statusCode == 200) { callback(response) } }); }

尝试使用Gmail的Node.js API修改标签时,“错误没有标签添加或删除指定”

我正在尝试使用gmail的Node.js API修改收件箱中的电子邮件标签。 我的function标记一个电子邮件为已读和明星是: function markAsRead(auth, req, res) { var gmail = google.gmail('v1'); console.log(req.body.id); gmail.users.messages.modify({ auth: auth, id: req.body.id, userId: 'me', resouce: { "addLabelIds": [ "STARRED" ], "removeLabelIds": [ "UNREAD" ] } }, function(err, response) { if (err) { console.log('…The API returned an error: ' + err); return; } console.log("Success???"); }); } 它给出了一个错误,说没有标签添加或删除指定。 我检查了电子邮件对象,并在labelIds属性“UNREAD”和“STARRED”出现,因此它们是有效的labelIds。 我似乎在做什么API的文档说是正确的,但它不断给出同样的错误。