Gmail API多个帐户 [英] Gmail API multiple accounts

查看:125
本文介绍了Gmail API多个帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有4个电子邮件帐户,我正在构建一个仪表板类型的网页,我想在所有4个邮件中显示未读邮件的数量。但是当我使用一个帐户进行身份验证时,它不会显示其他帐户的计数。

I have 4 gmails accounts, I am building a dashboard sort of web page, where i want to show number of unread mails in all of 4 mails. But When I auth with one account it doesn't displays the count of other accounts.

是否有任何方法可以保留多个帐户?

Is there any method to keep multiple accounts signed in?

我希望输出像;

邮件1:10未读邮件

邮件2:9未读邮件
等......

Mail 2: 9 unread mails so on....

推荐答案

我认为您可以在存储每个计数的凭证时执行此操作,例如:

i think that you can do it on storing the Credential for each count, for example :

if(Session["Credentials"]==null)
    List<UserCredential> Credentials= new List<UserCredential>();
esle
   List<UserCredential> Credentials=(List<UserCredential>)Session["Credentials"];

    UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                             new ClientSecrets
                             {
                                 ClientId = "Client_ID",
                                 ClientSecret = "Client_Secret"
                             },
                             Scopes,
                             "me",
                             CancellationToken.None,
                             new FileDataStore(path)

                             ).Result;
Credentials.Add(Credential); 
Session["Credentials"]=Credentials;

注意:您需要清除包含每个身份验证的ResponseToken的文件数据。

note : you need to clear the file data wich contain ResponseToken for each authentification.

这篇关于Gmail API多个帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆