Getting this error in MSOffice365 Scope

Trying to read mails from outlook using Get Mails activity but the fallowing error appearing and its frequency will be like after each 30 minutes error occuring. If any one has solution to this, please reply.

Error in retrieving mails…Status Code: 0
Microsoft.Graph.ServiceException: Code: generalException
Message: An error occurred sending the request.

—> System.TimeoutException: The client did not complete the authentication after 0 seconds, and as a result the operation was canceled. Authentication type: ApplicationIdAndSecret.
at UiPath.Shared.Services.Graph.GraphClientServiceFactory.TimeoutAfter[TResult](Task1 task, String authenticationType, Int32 timeoutMs) at UiPath.Shared.Services.Graph.GraphClientServiceFactory.LoginFromCacheOrExplicitAsync(OAuthDataOptions model, CancellationToken ct) at UiPath.Shared.Services.Graph.GraphClientServiceFactory.ResolveAccessTokenAsync(Task1 authResolver)
at UiPath.Shared.Services.Graph.GraphClientServiceFactory.AuthenticateAsync(OAuthDataOptions model, CancellationToken cancellationToken)
at UiPath.Shared.Authentication.Microsoft.Extensions.HttpRequestMessageExtensions.AuthorizeAsync(HttpRequestMessage request, Func2 getToken, CancellationToken ct) at Microsoft.Graph.AuthenticationHandler.SendAsync(HttpRequestMessage httpRequestMessage, CancellationToken cancellationToken) at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken) at Microsoft.Graph.SimpleHttpProvider.SendRequestAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken) --- End of inner exception stack trace --- at Microsoft.Graph.SimpleHttpProvider.SendRequestAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken) at Microsoft.Graph.SimpleHttpProvider.SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken) at Microsoft.Graph.BaseRequest.SendRequestAsync(Object serializableObject, CancellationToken cancellationToken, HttpCompletionOption completionOption) at Microsoft.Graph.BaseRequest.SendAsync[T](Object serializableObject, CancellationToken cancellationToken, HttpCompletionOption completionOption) at Microsoft.Graph.UserMailFoldersCollectionRequest.GetAsync(CancellationToken cancellationToken) at UiPath.Shared.Services.Graph.Mail.Extensions.GraphServiceClientExtensions.TryGetAllFoldersForAccount(IUserRequestBuilder account, CancellationToken cancellationToken) at UiPath.Shared.Services.Graph.Mail.Extensions.GraphServiceClientExtensions.GetMailFolder(IUserRequestBuilder account, String folderPath, CancellationToken cancellationToken) at UiPath.Shared.Services.Graph.Mail.Extensions.GraphServiceClientExtensions.GetMailAsync(GraphServiceClient graphClient, Boolean getAsHTML, String query, Nullable1 top, String address, String mailFolder, Boolean includeSubfolders, Nullable1 useSearchApi, String orderBy, CancellationToken cancellationToken) at UiPath.MicrosoftOffice365.Services.GraphServiceClientProxy.GetMailAsync(GetMailRequest request, CancellationToken cancellationToken) at UiPath.MicrosoftOffice365.Activities.Mail.GetMail.ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken) at UiPath.Shared.Activities.AsyncTaskCodeActivityImplementation.EndExecute(AsyncCodeActivityContext context, IAsyncResult result) at UiPath.Shared.Activities.AsyncTaskCodeActivity.EndExecute(AsyncCodeActivityContext context, IAsyncResult result) at UiPath.Shared.Activities.ContinuableAsyncCodeActivity.EndExecute(AsyncCodeActivityContext context, IAsyncResult result) at UiPath.MicrosoftOffice365.Activities.Office365BaseClientActivity.EndExecute(AsyncCodeActivityContext context, IAsyncResult result) at UiPath.MicrosoftOffice365.Activities.Office365ClientActivity2.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

Let us know which version of the UiPath O365 Package is used.
In newer versions maybe some other parts have to be touched as well

Ensure that the authentication part is also right configured at the Scope Activity

Hi,
I have used this package and authentication type
UiPath O365 Package Version: v2.6.22
Authentication type used: Application Id and Secret

@Moinodin,

It’s something to do with authentication interval. It might have set up in Active Directory app. If you can access the application on Azure portal, try looking for settings related authentication interval.

For immediate fix, you can use Retry Scope and put your logic inside it.

Thanks,
Ashok :slight_smile:

@Moinodin

Your error message indicates that the authentication process is timing out, also as you mentioned about the frequency of 30 minutes the access token being used for authentication is expiring after a certain period.

You can try implementing refresh token logic or adjust token expiration settings for your Outlook app for expiration times.

HAPPY AUTOMATION!!

this version needs sometimes the kick, described in the firstAid
ensure at the beginning, that AppId and Secret are set hardcoded at least for testing purposes

Also, ensure that setup config steps are done properly and that the authentication type is set appropriate