我正在尝试为android编写小型Gmail客户端作为培训。 我把https://developers.google.com/gmail/api/quickstart/android的gmail api指南样本修改了一下,以便通过线程获得标题为&的消息。我设置范围至GmailScopes.Gmail_modify
和编辑主请求的功能,因为这:Gmail API范围和格式不匹配
private List<String> getDataFromApi() throws IOException {
// Get the labels in the user's account.
String user = "me";
List<String> labels = new ArrayList<String>();
ListLabelsResponse listResponse =
mService.users().labels().list(user).execute();
ListThreadsResponse listThreads = null;
try {
listThreads = mService.users().threads().list(user).execute();
} catch (IOException ioex){
Log.e(LOG_TAG, "First: " + ioex.toString());
}
for (Thread thread : listThreads.getThreads()) {
try {
thread = mService.users().threads().get(user, thread.getId()).setFormat("full").execute();
} catch (IOException ioex){
Log.e(LOG_TAG, "Second: " + ioex.toString());
}
for(Message message : thread.getMessages()){
labels.add(message.getId());
}
}
return labels;
}
但我总是得到
Second: GoogleJsonResponseException: 403 Forbidden {
"code" : 403,
"errors" : [ {
"domain" : "global",
"message" : "Metadata scope doesn't allow format FULL",
"reason" : "forbidden"
} ],
"message" : "Metadata scope doesn't allow format FULL"
}
我尝试了不同的范围配置,但似乎像服务范围始终设置为GmailScopes.GMAIL_METADATA
你的意思是你从管理控制台删除你的范围并重新添加它们?我面临同样的问题。 – jpo