-
Notifications
You must be signed in to change notification settings - Fork 11
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
Support for OAuth over username/password #15
Comments
ExchangeLib supports this, https://ecederstrand.github.io/exchangelib/#setup-and-connecting I've also noticed the version of exchange lib this pack uses is wildly out of date. So I'll patch that bit first. The challenge with OAuth based workflows is how to signin without a browser/redirect flow. you need some sort of service token, if you can share a basic flow we could probably work out a solution |
These are the inputs needed: class OAuth2Credentials(BaseCredentials):
"""Login info for OAuth 2.0 client credentials authentication, as well as a base for other OAuth 2.0 grant types.
This is primarily useful for in-house applications accessing data from a single Microsoft account. For applications
that will access multiple tenants' data, the client credentials flow does not give the application enough
information to restrict end users' access to the appropriate account. Use OAuth2AuthorizationCodeCredentials and
the associated auth code grant type for multi-tenant applications.
"""
def __init__(self, client_id, client_secret, tenant_id=None, identity=None):
"""
:param client_id: ID of an authorized OAuth application, required for automatic token fetching and refreshing
:param client_secret: Secret associated with the OAuth application
:param tenant_id: Microsoft tenant ID of the account to access
:param identity: An Identity object representing the account that these credentials are connected to.
""" |
Alright so I've finally been able to circle back around to this. After understanding my needs this pack isn't setup to use Graph which is what our email admins have setup for me. So when I spoke of OAuth I was looking at OAuth for the Graph and not EWS in order to access our O365 mailbox. With that said, since this pack uses the EWS libraries exclusively I'm thinking maybe its best to look towards building a new pack to deal with Graph. Graph is overly complex to navigate and deal with. The library I've mentioned in my OP has the ability to use Graph and works well. |
Agreed that Graph support would fit nicely into a new pack. |
@amanda11 Should I close this issue as my needs have changed? It could still be a good feature to add OAuth to this library, but I don't have any way of testing these kind of changes. |
Its still a useful addition to this pack, so I think we can keep it open. |
Lots of companies, including ours, wont allow a basic username/password login for an Office365 account. Instead there's a usecase here for using client_id and client_secret for authenticating. If using exhangelib it should be able to be used using OAuth method: https://ecederstrand.github.io/exchangelib/#oauth-authentication.
I haven't tired doing this with exhangelib, but in the past I've used https://pypi.org/project/Office365-REST-Python-Client/ library which is easy to use when needing to use client credentials instead of username/password.
If I ever get some time in the next 10 years I'll try to contribute something.
The text was updated successfully, but these errors were encountered: