I was trying to use this module to authenticate against our SPO tenant but would keep getting "An error occurred while retrieving auth cookies from ...". I tried with ClientContext vs UserContext which worked fine but anytime I tried to pass user credentials with UserContext it failed.
By replacing
def is_valid_auth_cookies(values): return any(values) and values.get('FedAuth', None) is not None
with
def is_valid_auth_cookies(values): return any(values) and (values.get('FedAuth', None) is not None or (values.get('SPOIDCRL') is not None))
I hope this helps someone else out or, if I missed something, any guidance is always welcomed but at this point I can successfully connect to SPO using this module and pass the cookie along with subsequent requests.
I was trying to use this module to authenticate against our SPO tenant but would keep getting "An error occurred while retrieving auth cookies from ...". I tried with ClientContext vs UserContext which worked fine but anytime I tried to pass user credentials with UserContext it failed.
After some investigation it was due to is_valid_auth_cookies() looking explicitly for "FedAuth" which our SSO provider does not pass, instead I had to add a match for "SPOIDCRL" as mentioned in this article https://techcommunity.microsoft.com/t5/microsoft-sharepoint-blog/sharepoint-online-active-authentication/ba-p/510052.
By replacing
def is_valid_auth_cookies(values): return any(values) and values.get('FedAuth', None) is not None
withdef is_valid_auth_cookies(values): return any(values) and (values.get('FedAuth', None) is not None or (values.get('SPOIDCRL') is not None))
I hope this helps someone else out or, if I missed something, any guidance is always welcomed but at this point I can successfully connect to SPO using this module and pass the cookie along with subsequent requests.