У меня есть консольное приложение, использующее Graph API для обработки PDF-файлов, отправленных на адрес электронной почты. Я пытаюсь настроить мой API для обслуживания PDF-файлов, который находится в другом проекте. У меня есть аутентификация и создание клиента для графа в dll, так что все это делается одинаково и использует одну и ту же Azure информацию о приложении AD. В консольном приложении все прекрасно работает, но в API он не работает. Нужно ли предоставлять API как отдельное приложение в Azure? Это все, что я могу придумать. Код буквально тот же прямо сейчас и не работает. Никаких ошибок или чего-то еще, просто зависает навсегда, пытаясь получить что-нибудь из Office 365.
Спасибо. Ниже приведен рабочий код:
try
{
client = AuthenticationHelper.GetAuthenticatedClientForApp();
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Acquiring a token failed with the following
error: {0}", ex.Message);
if (ex.InnerException != null)
{
//You should implement retry and back-off logic per the
guidance given here:http://msdn.microsoft.com/en-us/library/dn168916.aspx
//InnerException Message will contain the HTTP error status
codes mentioned in the link above
Console.WriteLine("Error detail: {0}",
ex.InnerException.Message);
}
Console.ResetColor();
Console.ReadKey();
return;
}
try
{
String email = "mail@example.com";
Console.WriteLine("\nRetreiving email from: " + email);
var folders = client.Users[email].MailFolders.Inbox.ChildFolders.Request().GetAsync().Result;
Этот код не работает:
try
{
client = AuthenticationHelper.GetAuthenticatedClientForApp();
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Acquiring a token failed with the following error: {0}", ex.Message);
if (ex.InnerException != null)
{
//You should implement retry and back-off logic per the guidance given here:http://msdn.microsoft.com/en-us/library/dn168916.aspx
//InnerException Message will contain the HTTP error status codes mentioned in the link above
Console.WriteLine("Error detail: {0}", ex.InnerException.Message);
}
Console.ResetColor();
Console.ReadKey();
return null;
}
Attachment attachment = null;
try
{
String email = "email@example.com";
var folders = client.Users[email].MailFolders.Inbox.ChildFolders.Request().GetAsync().Result;