vgrem / Office365-REST-Python-Client

Microsoft 365 & Microsoft Graph Library for Python
MIT License
1.34k stars 335 forks source link

is_valid_auth_cookies() continually False, had to add values.get('SPOIDCRL') #306

Open nefariousOne opened 3 years ago

nefariousOne commented 3 years ago

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 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.

joshyu commented 3 years ago

Yes, I also met with this issue. always failed when checking the session cookie