小编Gre*_*een的帖子

Gmail api范围和格式不匹配

我正在尝试为Android编写一个小小的gmail客户端作为培训.我从https://developers.google.com/gmail/api/quickstart/android中获取了gmail api指南示例,对其进行了一些修改,以获取带有标题和正文的消息.我将范围设置为GmailScopes.Gmail_modify并编辑了主要请求函数,如下所示:

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());
                } …
Run Code Online (Sandbox Code Playgroud)

java android oauth-2.0 gmail-api

4
推荐指数
2
解决办法
3706
查看次数

标签 统计

android ×1

gmail-api ×1

java ×1

oauth-2.0 ×1