Recently, I started to see the following error in the gmail API:
{ "code" : 400, "errors" : [ { "domain" : "global", "message" : "Mail service not enabled", "reason" : "failedPrecondition" } ], "message" : "Mail service not enabled" }
Each gmail api call I tested causes an error, but the following code shows a normal example:
public static List<String> getThreadIdsFromRFC822MessageIds(Collection<String> messageIds, User u) throws IOException, NoOauthCredentialsException { List<String> queryTerms = new ArrayList<>(); for (String messageId: messageIds) { queryTerms.add("rfc822msgid:" + messageId); } String queryString = Joiner.on(" OR ").join(queryTerms); String fieldSelectionString = "messages/threadId"; ListMessagesResponse messages = executeMessageQuery(u, queryString, fieldSelectionString); List<String> threadIds = new ArrayList<>(); if (messages.getMessages() != null) { for (Message m : messages.getMessages()) { threadIds.add(m.getThreadId()); } } return threadIds; } private static ListMessagesResponse executeMessageQuery(User u, String queryString, String fieldSelectionString) throws IOException, NoOauthCredentialsException { assert fieldSelectionString.length() > 0; Gmail g = GmailAPIHelper.getGmailService(u); Gmail.Users.Messages.List query = g.users().messages().list("me").setQ(queryString).setFields(fieldSelectionString); ListMessagesResponse messages = executeAndLog(query, u); return messages; }
Where executeAndLog calls .execute in the Gmail.Users.Messages.List object.
This error only affects a very small number of my users, and the error message indicates that this is a permission issue. I expect that asking users to re-authorize will fix the problem, but I am worried that I get this error message instead of the more usual 401 when a permission issue occurs. Has anyone seen this error?
source share