gmail-api

Gmail Api return Unauthorized client or scope in request

我与影子孤独终老i 提交于 2019-12-04 06:13:23
问题 I have struggled to make this work but did half the job. Actually I can only read messages from Gmail API, If I try to use the gmail.modify Scope I get an error: HttpAccessTokenRefreshError: unauthorized_client: Unauthorized client or scope in request. Here is my code: # init gmail api credentials_path = os.path.join(settings.PROJECT_DIR, 'settings/gmail_credential.json') scopes = ['https://www.googleapis.com/auth/gmail.readonly', 'https://www.googleapis.com/auth/gmail.modify'] credentials =

刚刚学习到的Android使用Javamail通过XOauth调用Gmail API发送邮件的方法

天涯浪子 提交于 2019-12-04 05:52:08
前景知识: OAuth , Javamail-android , Javamail api in android using XOauth 我的一个App项目需要在Service中自动发送邮件的功能,因为是后台自动发送邮件,不能出现邮件UI所以需要使用Javamail来发送,在Android中并未包含Javamail,所以需要第三方lib: Javamail-android ;同时由于我的App的邮件发送服务不应保存用户的邮件帐号与密码(因为会有安全问题),所以就必须要用到 XOauth 的方式(也就是无需存储用户邮件帐号和密码的方式)来调用Gmail API来发送邮件。 关键在于 XOauth 的AuthToken的获取,在 这篇文章 中讲的很清楚了,需要使用AccountManager来获取 AuthToken,关键代码如下: AccountManager accountManager = AccountManager.get(context); //获得本机第一个google账号 Account me = accountManager.getAccountsByType("com.google")[0]; //注意在获得AUTHTOKEN前要invalidateAuthToken一下,否则会得到null的AUTHTOKEN accountManager

Access CHATS label with Gmail API

自闭症网瘾萝莉.ら 提交于 2019-12-04 05:12:01
问题 Does Gmail API provide a way to fetch Gmail chat logs? Chats is a label just like INBOX. I expected to find it in Users:label list but its not present. Is there something I have to enable to allow CHATS label to show up? Is this feature supported in Gmail API? 回答1: According to Find timestamp for hangout and chat messages retrieved with gmail api , the fact that chats show up in the Gmail API at all is a bug, not a feature. They are likely leaving it out of the list of labels intentionally.

Google's GMail API download attachments

谁都会走 提交于 2019-12-04 01:32:52
问题 I'm using the PHP SDK for the new Gmail API. How do I fetch an attachment from an email? Here is the API documentation, but in this instance, it's missing example for PHP. Although I have seen people achieving this with PHP. EDIT: This is what I have so far, unsure if it's correct: $attachmentData = $service->users_messages_attachments->get($emailAccount, $messageId, $attachmentId); $myfile = fopen("excel.xlsx", "w"); fwrite($myfile, $attachmentData); fclose($myfile); 回答1: Firstly we need to

How to extract full body content of a Bounced back email?

这一生的挚爱 提交于 2019-12-03 21:00:36
The above screenshot is the sample of the Bounced Back Mail received. I'm using the following code to extract the Body of the mail. function test() { var BouncedEmails = GmailApp.search("label:test The following message was undeliverable "); for( var i=0;i<BouncedEmails.length;i++) { var Gmessage = GmailApp.getMessagesForThread(BouncedEmails[i]); for(var j=0;j<Gmessage.length;j++) { var body = Gmessage[j].getPlainBody(); Logger.log(body); } } } But when I am doing this, I got the following output. As you can see the last part of the Body is missing, that is : I also tried using : var body =

How to edit Gmail messages as they arrive?

你离开我真会死。 提交于 2019-12-03 20:31:13
Ultimately my objective is to prevent email tracking via auto-loaded images with unique links. I'm aware that Google uses a proxy to load the images so at least they won't reveal my IP address, but there are certain individuals and organizations that annoyingly embed trackers into their emails -- and they actively check whether or not I read their emails. In the Gmail app specifically, I can turn off auto-loading of images, but I'd like to have similar protection for other apps that don't have this setting. For example, apparently there isn't a way to do this with Google Inbox . My current

Why does the GMail API strip the doctype and comments from outgoing messages?

一个人想着一个人 提交于 2019-12-03 20:07:11
The Gmail Message Send API appears to be stripping out doctype and HTML comments from outgoing messages. Repro Go to https://developers.google.com/gmail/api/v1/reference/users/messages/send Scroll down to "Try it!" Log in with OAuth For "userId" enter: me For "raw" enter the result of the following node script: generateMessage.js var email = "From: 'me'\r\n" + "To: bradvogel@outlook.com\r\n" + "Subject: Test Doctype\r\n" + "Content-Type: text/html; charset=utf-8\r\n" + "\r\n" + "<!doctype html>" + "<html><body>test <!--[if !mso]>hidden from outlook<!--<![endif]--> </body></html>"; var base64 =

How to parse JSON from Gmail API using JavaScript?

白昼怎懂夜的黑 提交于 2019-12-03 18:07:50
问题 Using JavaScript, how do I extract the Date, To, From, Subject and Text fields from the Gmail API's return (see below)? It's not in the usual name-value pair, at least not how I would do it with JSON. Also, the text needs to be decoded. { "id": "rthrt34t34t45g45g4", "threadId": "gg54tgw4y45t24f3f", "labelIds": [ "SENT" ], "snippet": "Testing 1 2 3", "historyId": "2344", "payload": { "mimeType": "multipart/alternative", "filename": "", "headers": [ { "name": "MIME-Version", "value": "1.0" }, {

Python - Extract the body from a mail in plain text

寵の児 提交于 2019-12-03 17:15:37
问题 I want to extract only the body of a message and return it. I can filter on the fields and display the snippet but not the body. def GetMimeMessage(service, user_id, msg_id): try: message = service.users().messages().get(userId=user_id, id=msg_id, format='raw').execute() print 'Message snippet: %s' % message['snippet'] msg_str = base64.urlsafe_b64decode(message['raw'].encode('ASCII')) mime_msg = email.message_from_string(msg_str) return mime_msg except errors.HttpError, error: print 'An error

Lots of threads missing in Users.threads.list()

倾然丶 夕夏残阳落幕 提交于 2019-12-03 17:00:38
I am retrieving threads from my GMail account using the Users.threads.list method, with the query "in:sent newer_than:1y". The first page of results (100 threads) looks OK, with threads from Dec 2014 and Jan 2015. However, the second page starts at June 2014, and goes back to May 2014 etc. It looks like whole pages of threads are missing for the months of July-November 2014. I have reproduced this using the in-page API tester at https://developers.google.com/gmail/api/v1/reference/users/threads/list . Everything looks fine in GMail's web interface. I'm pretty sure this worked yesterday, i.e. I