Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Ability to timeout at authentication phase #1102

Open
jovimon opened this issue Sep 24, 2024 · 3 comments
Open

Feature request: Ability to timeout at authentication phase #1102

jovimon opened this issue Sep 24, 2024 · 3 comments

Comments

@jovimon
Copy link

jovimon commented Sep 24, 2024

Hello,

I am having trouble trying to automate the download of some emails from a mailbox.

I want the script to exit with a timeout error and warn me if the authentication cannot be completed, instead of just waiting for input at the "Paste the authenticated url here:" phase (here in the code, I guess: https://github.com/O365/python-o365/blob/master/O365/connection.py#L983).

I tried passing the timeout parameter to both the Account creation and the account.authenticate function, without success.
This is the relevant part of the code.

account = Account(credentials, tenant_id=tenant_id, token_backend=token_backend, timeout=60.0) 
if not account.is_authenticated:
  if account.authenticate(scopes=scopes, timeout=60.0):
    mylogger.info('Successfully authenticated!')

And this is where it stops after being launched.

$ python test_o365.py
Visit the following url to give consent:
https://login.microsoftonline.com/[ ... ]/oauth2/v2.0/authorize?response_type=code&client_id=[ ... ]&redirect_uri=https%3A%2F%2Flogin.microsoftonline.com%2Fcommon%2Foauth2%2Fnativeclient&scope=[ ... ]&state=[ ... ]&access_type=offline&timeout=60.0
Paste the authenticated url here:

Could you possibly add a timeout feature here?

Thank you very much.

Kind regards.

@alejcas
Copy link
Member

alejcas commented Sep 30, 2024

You have the Requests session object inside account.con. You can change the session to timeout. Follow Requests docs to do this

@jovimon
Copy link
Author

jovimon commented Oct 1, 2024

Dear @alejcas ,
Thank you for your response. I'm having trouble with the input function that shows the "Paste the authenticated url here:" text, not the Requests session.
For me, the best option would be that the input function has some sort of timeout, but I don't know how to implement it :(

@alejcas
Copy link
Member

alejcas commented Oct 1, 2024

Ohh I see. The default auth method uses the console. There’s no possibility of a timeout there. You should implement another method that allows that. look through the readme

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants