Click here to Skip to main content
15,886,091 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a console application which tried to connect to mailbox for processing the mails. program uses OAuth 2.0 for outlook authentication. Application will load user interactive window for the authentication using IPublicClientApplication.AcquireTokenInteractive() method. This authentication needed only for the first time to run the application. Application works fine. However when i convert this application to Windows service or a scheduler job, its giving the error "Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application."

How can perform OAuth 2.0 authentication (IPublicClientApplication.AcquireTokenInteractive() method) from a windows service or scheduler job. This interactive token acquiring is needed only for first time, after that application will acquire the token silently.

What I have tried:

tried , Use Azure Active Directory authentication to send messages to a Service Bus queue | Microsoft Docs[^] and
Get access without a user - Microsoft Graph | Microsoft Docs[^]
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900