GithubHelp home page GithubHelp logo

Comments (12)

mguessan avatar mguessan commented on May 21, 2024 3

Makes sense, please check latest trunk for a command line implementation of manual authentication.
Please also set davmail.mode to O365Manual, no need to try OpenJFX browser in your case.

You should probably also try to enable token persistence with:
davmail.oauth.persistToken=true

This will drastically reduce user interaction.

from davmail.

rschmied avatar rschmied commented on May 21, 2024 1

Can we make interactive mode work on the CLI? Basically, what works for me in UI mode is the popup window that uses xdg-open to start the browser and then allows me to insert the resulting token into the window input line and finally clicking OK.

What I did is to replace xdg-open with a shell script that copies the link into a file, I open that link with my browser outside of the container and then paste the resulting token back into the DavMail UI window.

For me it would be nice if DavMail would support that "interactive" workflow in headless mode. E.g.

  • print the link on stdout
  • prompt the user for the token on stdin
  • CLI paste / return

This way, I could run in headless mode again (running the container attached to a tty inside of tmux) and do the UI auth bits outside of the container without the need to do fancy X11 forwarding and library installation to support the UI.

from davmail.

mguessan avatar mguessan commented on May 21, 2024

This may be a device authentication issue => after authentication O365 checks that client has a valid certificate. As your Docker container obviously is not registered this will not work.

Anyway, you should first find the right settings with DavMail in client mode, with O365Interactive or O365Manual.

from davmail.

kosli avatar kosli commented on May 21, 2024

Thanks @mguessan
Where do I find more information about the O365Manual mode? Does this work in "headless" mode too?
How do I make sure that davmail has a valid client certificate? I see how I can store it, but how do I create it? (http://davmail.sourceforge.net/sslsetup.html)

from davmail.

mguessan avatar mguessan commented on May 21, 2024

Nope, O365Manual and O365Interactive open authentication dialogs and will thus not work in headless mode.
However this can help you find the right settings

from davmail.

mguessan avatar mguessan commented on May 21, 2024

Please make sure you test in standalone mode before trying server/docker/headless mode.

You may have to use another clientId, see:
https://sourceforge.net/p/davmail/bugs/702/

Once you have it working in standalone mode, we can troubleshoot headless mode.

from davmail.

rschmied avatar rschmied commented on May 21, 2024

small correction... apparently, DavMail switches to manual mode when the proper libraries aren't installed. So in my case, I could see this:

2019-10-07 09:15:08,214 WARN  [AWT-EventQueue-0] davmail.exchange.auth.O365InteractiveAuthenticator  - Unable to load JavaFX (OpenJFX), switch to manual mode

which resulted in the "input OAUTH token" window / dialog which is perfectly fine for my workflow even though it requires the extraction of the Location header from the final POST response.

from davmail.

rschmied avatar rschmied commented on May 21, 2024

Tried with latest trunk. However, the code in ExchanceSessionFactory.java checks if we run in headless mode and then throws an exception if auth mode is set to O365Manual or O365Interactive. At least for O365Manual, that restriction needs to be removed.

from davmail.

mguessan avatar mguessan commented on May 21, 2024

Indeed, can you please test again ?

from davmail.

rschmied avatar rschmied commented on May 21, 2024

thanks... one step further but no success yet.

2019-10-09 22:10:44,912 ERROR [ImapConnection-49858] davmail  - Authentication failed null
davmail.exception.DavMailException: Authentication failed null
	at davmail.exchange.auth.O365ManualAuthenticator.authenticate(O365ManualAuthenticator.java:137)
	at davmail.exchange.ExchangeSessionFactory.getInstance(ExchangeSessionFactory.java:177)
	at davmail.exchange.ExchangeSessionFactory.getInstance(ExchangeSessionFactory.java:93)
	at davmail.imap.ImapConnection.run(ImapConnection.java:139)
Please open the following link:
https://login.microsoftonline.com/common/oauth2/authorize?client_id=...
 proceed through authentication steps and paste back the final url that contains authentication code (blank page)
Authentication code: 2019-10-09 22:10:44,915 ERROR [ImapConnection-49858] davmail.exchange.auth.O365ManualAuthenticator  - Authentication failed, code not available
2019-10-09 22:10:44,915 ERROR [ImapConnection-49858] davmail  - Authentication failed null
davmail.exception.DavMailException: Authentication failed null
	at davmail.exchange.auth.O365ManualAuthenticator.authenticate(O365ManualAuthenticator.java:137)
	at davmail.exchange.ExchangeSessionFactory.getInstance(ExchangeSessionFactory.java:177)
	at davmail.exchange.ExchangeSessionFactory.getInstance(ExchangeSessionFactory.java:93)
	at davmail.imap.ImapConnection.run(ImapConnection.java:112)

I paste the link into the console and hit return. The string contains the code and session_state query parms. It basically is this (which worked with the dialog when pasted there, so I assume it's the right thing):

urn:ietf:wg:oauth:2.0:oob?code=somelongalphanumstring&session_state=some-uuid

I guess a bit more logging inside the getCodeFromConsole method would be useful to figure out whether it actually read the string and extracted the code. Maybe even print the extracted code again at debug level or something. Thanks again!

from davmail.

rschmied avatar rschmied commented on May 21, 2024

OK. My fault. I did add the instrumentation code and build it from trunk myself to realize that I of course need a tty in the container... otherwise the readLine() will instantly return as stdin is eof. Looking good. Works for me :) Thanks!

from davmail.

mguessan avatar mguessan commented on May 21, 2024

Great, thanks for your feedback => closing issue.

from davmail.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.