Questions tagged [gmail-api]

Use the Gmail API to add Gmail features to your app. RESTful access to threads, messages, labels, drafts and history. Easy to use from modern web languages.

Gmail API() gives you flexible, RESTful access to the user's inbox, with a natural interface to Threads, Messages, Labels, Drafts, and History. From the modern language of your choice, your app can use the API to add Gmail features like:

  • Read messages from Gmail
  • Send email messages
  • Modify the labels applied to messages and threads
  • Search for specific messages and threads

References:

4233 questions
15
votes
3 answers

Trying to send email via Service Account getting com.google.api.client.auth.oauth2.TokenResponseException: 401 Unauthorized

I have a Google Apps account. I'm trying to simply send an email on behalf of a user using a Service Account. I've scoured the internet and nothing is working and i'm nearly at a loss. I've followed the Java guides and i still keep getting…
Catfish
  • 18,876
  • 54
  • 209
  • 353
15
votes
1 answer

Gmail API users.watch - no details for historyId

I have successfully set up Google Pub/Sub to use Gmail API Watch feature as described here: https://developers.google.com/gmail/api/guides/push to watch INBOX label in my gmail account. Once new message arrive I instantly get a push notification in…
Yaroslav Pogrebnyak
  • 1,117
  • 9
  • 22
14
votes
1 answer

Get direct URL to email from Gmail API (list messages)

I am retrieving messages from the Google Gmail API in Node.JS, but i'm having trouble generating or retrieving the direct link to the emails. Currently, I am using the following code: var link = 'https://mail.google.com/mail/u/0/#inbox/' +…
Tijme
  • 39
  • 2
  • 24
  • 41
14
votes
5 answers

Where to find body of email depending of mimeType

I am making a request to the User.messages endpoint. All objects returned (the emails) have a mimeType property which I'm struggling to understand. More specifically, I want to be able to extract the body of the email depending of the mimeType since…
jgozal
  • 1,480
  • 6
  • 22
  • 43
14
votes
7 answers

Using Refresh Token Exception { "error" : "invalid_grant" }'

I've successfully built an application that fetches an access and refresh token. In my script I check if the access token is valid and if not I then use the refresh token to gain access $client->refreshToken($refreshToken); Code in full, …
Jack Trowbridge
  • 3,175
  • 9
  • 32
  • 56
14
votes
2 answers

Is there a way in Gmail API to include extra fields (e.g. subject, body) in the message list method?

The "Try it" part documentation allows me to play the API, and the field selector allow me to select a lot of fields, e.g. header, raw, etc. But none of them actually showed up when tried the API. The only thing I saw were still just the message ID…
yuklai
  • 1,595
  • 1
  • 14
  • 26
13
votes
2 answers

'com.google.api.client.json.jackson2.JacksonFactory' is deprecated. What are my options?

While following the Gmail API java quickstart guide I came across this code snippet: private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance(); Using it in the editor gave me a warning that it is deprecated. What are my…
13
votes
1 answer

Disable checkboxes on Google consent screen

We're implementing Gmail sending in out ASP .NET web application with Gmail .NET SDK. In order to do this we need all following scopes "email", "profile", "openid", https://www.googleapis.com/auth/gmail.send" to be granted to us by user. However, on…
13
votes
4 answers

How to get avatar for gmail user?

I'm creating an email-based application in React with the Gmail API. I'm loading in a bunch of messages, and I want to display avatars of the senders. I'm using this package to display avatars. I'd like to either have a Google Id or an image url. It…
kognise
  • 612
  • 1
  • 8
  • 23
13
votes
1 answer

Adding multiple recipients using google api in python?

I have been using the guides for the gmail api to create drafts. The following code has been working well. def create_message(sender, to, subject, message_text): message = MIMEText(message_text) message['to'] = to message['from'] = sender …
James L
  • 350
  • 1
  • 3
  • 13
13
votes
5 answers

What is the encoding of the body of Gmail message? How to decode it?

I am using the Python API for Gmail. I am querying for some messages and retrieving them correctly, but the body of the messages looks like total nonsense, even when the MIME type it's said to be text/plain or text/html. I have been searching all…
houcros
  • 1,000
  • 1
  • 14
  • 32
13
votes
2 answers

Send a email with Attachment in R using Gmail

I am trying to attach a file from my system to send it to an email id using R. I am using the gmailr package to send the mails. I have tried the following code for the same. library(gmailr) mime() %>% to("abcd@gmail.com") %>% from("xyz@gmail.com")…
Kshitij Marwah
  • 1,091
  • 3
  • 14
  • 23
13
votes
2 answers

Gmail API configuration issue (in Java)

Here is my Gmail service configuration/factory class: import java.io.File; import java.io.IOException; import java.security.GeneralSecurityException; import org.springframework.beans.factory.annotation.Autowired; import…
user3029106
  • 201
  • 3
  • 8
13
votes
2 answers

Sending email with signature using Gmail API

I got the Gmail Rest API sending part working but the e-mail doesn't include the signature and in recipient's inbox the 'from' label is sender's user id not the name of the user. This is in php. $mime = new Mail_mime(); …
13
votes
7 answers

Mark as read mail method

How do I mark mail as read using Gmail API? I got the thread of email Thread thread = service.users().threads().get(userId, message.getThreadId()).execute(); but it does not have method markRead like gmail API site says it should.
Kun Dark
  • 141
  • 1
  • 2
  • 6