Gmail API multiple accounts

。_饼干妹妹 提交于 2019-12-23 16:24:55

问题


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?

I want output like;

Mail 1: 10 unread Mails

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


回答1:


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;

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



来源:https://stackoverflow.com/questions/51398912/gmail-api-multiple-accounts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!