Hi,
since Microsoft plans to disable Basic authentication on Office 365 servers using username and password (ews.Login(username, password)
method in our API) in second half of year 2021, you have to use OAUth token, which you are attempting but with wrong procedure. There are more than one scenario how you can obtain an OAuth token from Microsoft. It is up to you how you obtain an OAuth token and that token you use in ews.Login(token, EwsAuthentication.OAuth)
method only.
You can use code grant flow or client credential grant flow, device code flow should work too. You can get the token by implementing the process described on those pages or use Microsoft Authentication Libraries downloadable from NuGet to obtain your OAuth token. In any case you have to register your application on Azure and set it up properly there. This registration gives you an ID which you use in any method of your choice when obtaining an OAuth token.