diff --git a/pyews/core/authentication.py b/pyews/core/authentication.py index 74b811b..38d04d4 100644 --- a/pyews/core/authentication.py +++ b/pyews/core/authentication.py @@ -30,7 +30,7 @@ def oauth2_authorization_type(cls): @oauth2_authorization_type.setter def oauth2_authorization_type(cls, value): - if value in ['legacy_app_flow', 'auth_code_grant', 'client_credentials_grant', 'backend_app_flow', 'web_application_flow', 'implicit_grant_flow']: + if value in ['interactive_auth_code_grant', 'legacy_app_flow', 'auth_code_grant', 'client_credentials_grant', 'backend_app_flow', 'web_application_flow', 'implicit_grant_flow']: cls._oauth2_authorization_type = value cls.__set_initial_property_values() diff --git a/pyews/core/oauth2connector.py b/pyews/core/oauth2connector.py index 8370f38..dbfafe0 100644 --- a/pyews/core/oauth2connector.py +++ b/pyews/core/oauth2connector.py @@ -85,6 +85,29 @@ def __build_query_param_url(self, url, params): url_parse = url_parse._replace(query=url_new_query) return urlunparse(url_parse) + def interactive_auth_code_grant(self): + oauth = OAuth2Session( + client_id=self.client_id, + redirect_uri=self.redirect_uri, + scope=self.scope + ) + authorization_url, state = oauth.authorization_url( + self.authorize_url, + ) + auth_code = self.__prompt_user(authorization_url) + response = self.session.request( + 'POST', + self.token_url, + data={ + "client_id": self.client_id, + "code": auth_code, + "grant_type": "authorization_code", + "redirect_uri": self.redirect_uri, + "client_secret": self.client_secret + } + ) + return response.json() + def auth_code_grant(self): """Authorization Code Flow Grant Reference: https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow diff --git a/setup.py b/setup.py index df1ef18..567cf88 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ def parse_requirements(requirement_file): setup( name='py-ews', - version='3.0.0', + version='3.1.0', packages=find_packages(exclude=['tests*']), license='MIT', description='A Python package to interact with both on-premises and Office 365 Exchange Web Services',