vgrem / Office365-REST-Python-Client

Microsoft 365 & Microsoft Graph Library for Python
MIT License
1.29k stars 332 forks source link

"An error occurred while retrieving auth cookies" - v2.3.4 #368

Open kayx23 opened 3 years ago

kayx23 commented 3 years ago

Error Retrieving Auth Cookie:

ValueError: An error occurred while retrieving auth cookies from https://mycompany.com/_forms/default.aspx?wa=wsignin1.0

Company is using ADFS.

Relevant Issue:

Traceback:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-57-0e785716fbed> in <module>()
      1 ctx_auth = AuthenticationContext(url)
      2 
----> 3 if ctx_auth.acquire_token_for_user(username, password):
      4     ctx = ClientContext(url, ctx_auth)
      5     web = ctx.web

C:\ProgramData\Anaconda3\lib\site-packages\office365\runtime\auth\authentication_context.py in acquire_token_for_user(self, username, password, browser_mode)
     73         self._provider = SamlTokenProvider(url=self.url, username=username, password=password,
     74                                            browser_mode=browser_mode)
---> 75         return self._provider.ensure_authentication_cookie()
     76 
     77     def acquire_token_for_app(self, client_id, client_secret):

C:\ProgramData\Anaconda3\lib\site-packages\office365\runtime\auth\providers\saml_token_provider.py in ensure_authentication_cookie(self)
     82     def ensure_authentication_cookie(self):
     83         if self._cached_auth_cookies is None:
---> 84             self._cached_auth_cookies = self.get_authentication_cookie()
     85         return True
     86 

C:\ProgramData\Anaconda3\lib\site-packages\office365\runtime\auth\providers\saml_token_provider.py in get_authentication_cookie(self)
     98             else:
     99                 token = self._acquire_service_token()
--> 100             return self._get_authentication_cookie(token, user_realm.IsFederated)
    101         except requests.exceptions.RequestException as e:
    102             logger.error(e.response.text)

C:\ProgramData\Anaconda3\lib\site-packages\office365\runtime\auth\providers\saml_token_provider.py in _get_authentication_cookie(self, security_token, federated)
    244                 self._sts_profile.signin_page_url)
    245             logger.error(self.error)
--> 246             raise ValueError(self.error)
    247         return cookies
    248 

ValueError: An error occurred while retrieving auth cookies from https://mycompany.com/_forms/default.aspx?wa=wsignin1.0

Also tried 2.2.0 and 2.2.2 and I get:

An error occurred while retrieving token from XML response: AADSTS500127: No authenticated credentials found in request.
markprovenioai commented 2 years ago

I am also experiencing this error. Were you able to resolve the issue?

kayx23 commented 2 years ago

@markprovenioai Not yet unfortunately

yene commented 2 years ago

Had the same thing 1 in a 100, could not reproduce.

Azee77 commented 6 months ago

any plans to fix this? or how to handle it separetely? Even though the occurrence frequency is less, it impacts much while performing multiple actions back to back I can accept work arounds too