标签: gmail-api

Gmail Oauth API可获取邮件数量

新的Gmail API现在允许对标签中的总电子邮件和未读电子邮件进行邮件计数.但我无法让它工作并尝试了很多东西.它正确连接到Oauth,但无法使计数生效.我正在使用以下代码: -

$labelall = $service->users_labels->listUsersLabels('me');
        $labels = $labelall->getLabels();
     foreach ($labels as $label) {
         print 'Label with ID: ' . $label->getId() . ', 
Number of Messages:'.$label->getMessagesTotal().'<br/>';}
Run Code Online (Sandbox Code Playgroud)

有人可以帮忙吗?它正确列出标签,但消息计数返回null.

谢谢!

php google-oauth gmail-api

3
推荐指数
1
解决办法
518
查看次数

使用身份验证范围https://mail.google.com/访问Gmail API时的access_denied

我正在尝试使用Gmail REST API读取/写入Gmail邮箱中的电子邮件/文件夹.添加以下Google身份验证范围时,可以从Gmail REST API中读取电子邮件,而不会出现任何问题:

https://apps-apis.google.com/a/feeds/compliance/audit/, https://www.googleapis.com/auth/admin.directory.user.readonly,https://www.googleapis.com /auth/gmail.readonly, https://www.googleapis.com/auth/admin.directory.group.member.readonly,https://www.googleapis.com/auth/admin.directory.group.readonly

注意:参数https://www.googleapis.com/auth/gmail.readonly正确允许用户从邮箱中读取.

但是,我也需要能够删除电子邮件.因此,根据https://developers.google.com/gmail/api/auth/scopes?hl=ja上的文档,只需要包含https://mail.google.com/代替https: //www.googleapis.com/auth/gmail.readonly.添加以下auth范围时:

https://apps-apis.google.com/a/feeds/compliance/audit/, https://www.googleapis.com/auth/admin.directory.user.readonly,https://mail.google.com /, https://www.googleapis.com/auth/admin.directory.group.member.readonly,https://www.googleapis.com/auth/admin.directory.group.readonly

...输出的错误如下:

    2015-07-27 10:27:59 i.c.s.a.cv [DEBUG] failed get labels for user
    com.google.api.client.auth.oauth2.TokenResponseException: 403 Forbidden
    {
       "error" : "access_denied",
       "error_description" : "Requested client not authorized."
    }
Run Code Online (Sandbox Code Playgroud)

当然,谷歌这是不正确的?我错过了什么?文档不正确吗?需要添加什么认证范围?

我正在与Java Google API客户端库连接.请参阅:https://developers.google.com/api-client-library/java/google-api-java-client/reference/1.20.0/overview-summary

删除请求如下:

public void deleteMessages(Queue<String> messages, GoogleUserAdapter user) throws Exception {

    Gmail gmail = …
Run Code Online (Sandbox Code Playgroud)

gmail-api

3
推荐指数
1
解决办法
2446
查看次数

通过自定义标头搜索gmail api

我试图用自定义标头搜索gmail api(这种情况下它被命名为 notification-id),但它不起作用.请求我正在制作:

GET https://www.googleapis.com/gmail/v1/users/tme/messages?includeSpamTrash=true&q=notification-id%3A560d01cef318893c3c000016
Run Code Online (Sandbox Code Playgroud)

我使用来自google mail api的默认标头(rfc822msgid)尝试了相同的查询,它可以处理此请求: GET https://www.googleapis.com/gmail/v1/users/me/messages?includeSpamTrash=true&q=rfc822msgid%3A560d01d068c_6690c6f31857290%40ip-172-31-12-127.mail

任何想法为什么它不适用于自定义标题?

email search email-headers gmail-api

3
推荐指数
1
解决办法
867
查看次数

如何使用Gmail api在swift中发送电子邮件

Gmail的阿比对如何做到这一点,我一直在努力,没有清晰的文档,但有很多事情是在空气中.

我曾寻求过这样的外部资源.来源1来源2.第一个似乎使用api的潜力,使用该函数queryForUsersMessagesSendWithUploadParameters.

而第二个是多一点.尽管在Objective-C中这不是问题,但GTMMIMEDocument对象除外,它不知道在何处或是否获得它或库.

我的问题是,是否有人更容易理解更清洁和/或代码,或者更好的发送电子邮件的指南

email api ios swift gmail-api

3
推荐指数
1
解决办法
6691
查看次数

您如何测试Gmail上下文小工具?

在他们的文档中,链接似乎都解析为https://developers.google.com/apps-marketplace/ - 似乎没有任何号召性用语.如何测试Gmail上下文小工具?在哪里上传清单和小工具规范?

google-gadget gmail-contextual-gadgets gmail-api

3
推荐指数
1
解决办法
531
查看次数

gapi.client.gmail.users.labels.create给出了invalidArgument错误

我正致力于使用JavaScript Gmail API创建标签.

function createLabel(userId, newLabelName, callback) {
var request = gapi.client.gmail.users.labels.create({
'userId': userId,
'label': {'name': newLabelName}
});
request.execute(callback);}
Run Code Online (Sandbox Code Playgroud)

这是Developer API Example的代码

我能够进行身份验证,甚至我将获得标签列表,但在创建标签时,我收到以下错误.

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "invalidArgument",
    "message": "Invalid request"
   }
  ],
  "code": 400,
  "message": "Invalid request"
 }
}
Run Code Online (Sandbox Code Playgroud)

但是当我使用Try It示例时它正在工作,但唯一不同的是它使用key = {Your auth key}执行POST请求,该示例提供的不会将该部分附加到URL.

javascript gmail-api

3
推荐指数
1
解决办法
438
查看次数

当minifyEnabled = true时,GMail API无法正常工作

我正在开发一个使用GMail API发送电子邮件的Android应用程序.我在Android Quickstart发送电子邮件时使用了示例代码,当我调试应用程序时,一切正常.当我用它构建发布版本时会出现问题minifyEnabled=true.在这种情况下,调用service.users().messages().send(userId, message).execute();会出错IOException.异常消息是"404 Not Found".

ProGuard的文件包括所有的-keep class-dontwarn我在其他帖子发现:

-dontwarn com.google.**
-dontwarn java.awt.**
-dontwarn javax.security.**
-dontwarn java.beans.**

-keep class com.google.**
-keep public class Mail {*;}
-keep class com.sun.activation.** {*;}
-keep class com.sun.activation.registries {*;}
-keep class javamail.** {*;}
-keep class javax.mail.** {*;}
-keep class javax.activation.** {*;}
-keep class com.sun.mail.dsn.** {*;}
-keep class com.sun.mail.handlers.** {*;}
-keep class com.sun.mail.smtp.** {*;}
-keep class com.sun.mail.util.** {*;}
-keep class mailcap.** {*;}
-keep class …
Run Code Online (Sandbox Code Playgroud)

android gmail-api android-proguard

3
推荐指数
1
解决办法
449
查看次数

禁用gmail api请求缓存

我正在使用javascript gmail api来使用threadId获取电子邮件线程.我使用以下代码:

var request = gapi.client.gmail.users.threads.get({
  'userId': 'me',
  'id': '123abc'
});

request.execute(function(response) {

    var messages = response.messages;

});
Run Code Online (Sandbox Code Playgroud)

这是第一次特定的threadId,它工作正常.并且对于进一步的请求,即使线程有更多的电子邮件,它也会返回相同数量的消息.但是,如果我从Chrome开发者工具 - 网络选项中清除gapi网址的浏览器缓存,则响应会提供正确数量的电子邮件.

例:

- >使用threadId'123abc'执行请求,目前线程中有3封电子邮件.请求的响应是正确的,长度为3 response.messages.

- >然后我再发一封电子邮件作为回复此帖子,然后再次执行相同的请求.但是响应仍然是长度为3的旧响应response.messages.

- >尝试多次运行相同的请求但得到相同的响应.

- >然后清除此网址的浏览器缓存并再次请求,现在响应正确,长度为4 response.messages.

尝试在html页面中添加以下元标记,但不起作用:

<meta http-equiv='cache-control' content='no-cache'>
<meta http-equiv='expires' content='0'>
<meta http-equiv='pragma' content='no-cache'>
Run Code Online (Sandbox Code Playgroud)

尝试添加随机数与页面网址和请求,但没有工作.

尝试使用gapi脚本链接添加随机数,但没有奏效 <script src="https://apis.google.com/js/client.js?onload=AuthIt&cacheBurster=123123123123"></script>

是否有任何代码可以禁用gapi请求缓存或任何其他方法来解决此问题?

javascript browser-cache gmail-api gapi

3
推荐指数
1
解决办法
322
查看次数

如何使用Gmail API,OAuth2 for Apps脚本和域范围委派为G Suite域中的用户设置电子邮件签名

这是我发布的上一个问题/答案的后续内容(如何使用Google电子邮件设置API和OAuth2 for Apps脚本库为Google Apps域中的用户设置电子邮件签名),但我正在创建一个新的问题,因为电子邮件设置API已被弃用,现在流程明显不同.

作为G Suite域的管理员,您如何使用Gmail API 以编程方式通过Google Apps脚本设置域中用户的电子邮件签名?

email google-apps google-apps-script gmail-api google-oauth2

3
推荐指数
1
解决办法
1850
查看次数

Gmail API阅读邮件

我正在尝试使用gmail api阅读电子邮件.但是正文消息的格式是不可读的.

static void Main(string[] args)
    {
        UserCredential credential;

        using (var stream =
            new FileStream("client_secret.json", FileMode.Open, FileAccess.Read))
        {
            string credPath = System.Environment.GetFolderPath(
                System.Environment.SpecialFolder.Personal);
            credPath = Path.Combine(credPath, ".credentials/gmail-dotnet-quickstart.json");

            credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                GoogleClientSecrets.Load(stream).Secrets,
                Scopes,
                "user",
                CancellationToken.None,
                new FileDataStore(credPath, true)).Result;
            Console.WriteLine("Credential file saved to: " + credPath);
        }

        // Create Gmail API service.
        var service = new GmailService(new BaseClientService.Initializer()
        {
            HttpClientInitializer = credential,
            ApplicationName = ApplicationName,
        });


        UsersResource.MessagesResource.ListRequest request = service.Users.Messages.List("me");
        IList<Message> messages = request.Execute().Messages;
        if (messages != null && messages.Count > 0) …
Run Code Online (Sandbox Code Playgroud)

c# gmail-api

3
推荐指数
1
解决办法
2604
查看次数