I am trying to read gmail messages using Gmail IMAP Oauth. I want to use Oauth 2.0 scope “https://www.googleapis.com/auth/gmail.readonly
but aspose fails with exception “Unable connect to server”.
When i use Oauth 2.0 scope “https://mail.google.com/”
, It works fine.
string AccessToken = credential.Token.AccessToken;
ImapMessageInfoCollection messageInfoCol = null;
ImapClient client = null;
client = new ImapClient(“[imap.gmail.com](http://imap.gmail.com/)”, 993, “[sangapankaj@gmail.com](mailto:sangapankaj@gmail.com)”, AccessToken, true);
{
try
{
client.SecurityOptions = SecurityOptions.SSLImplicit;
client.SelectFolder(“Inbox”); //Exception is raised here when i use gmail readonly scope
messageInfoCol = client.ListMessages();
foreach (ImapMessageInfo mess in messageInfoCol)
{
MailMessage mailMessage = client.FetchMessage(mess.UniqueId);
}
}
catch (Exception e)
{
}
}
/////////////////////////////////////////////////////
Test project “OauthTest.zip” OauthTest.zip (3.7 MB)
GCred.zip (430 Bytes)
(visual studio 2019) is attached.