我正在嘗試爲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