Office365-REST-Python-Client icon indicating copy to clipboard operation
Office365-REST-Python-Client copied to clipboard

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

Open kayx23 opened this issue 3 years ago • 4 comments

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:

  • https://github.com/vgrem/Office365-REST-Python-Client/issues/308

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.

kayx23 avatar Jun 21 '21 21:06 kayx23

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

markprovenioai avatar Sep 29 '21 01:09 markprovenioai

@markprovenioai Not yet unfortunately

kayx23 avatar Sep 29 '21 05:09 kayx23

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

yene avatar May 18 '22 12:05 yene

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

Azee77 avatar Feb 21 '24 04:02 Azee77