The documentation for the ArcGIS API for Python doesn't seem to cover the scenario for logging in to ArcGIS Online that my agency uses. I log into https://wsdot.maps.arcgis.com using my Windows domain account (active directory) which somehow invol...https://sts.wsdot.wa.gov/adfs/ls/auth/integrated/?SAMLRequest=...
The only way I have figured out to log in is to have ArcGIS Pro already open and logged in, but this is not a viable solution for the script I am creating.
This has been a challenge for our organization for the past few years as well. We finally put together an authentication handler that works with the python requests API which supports the esri proprietary "token authentication", web-tier using Kerberos (or ntlm) and SAML with enterprise logins.
Code repo is on git hub GitHub - DOI-BLM/requests-arcgis-auth: Authentication handler for using Esri ArcGIS for Server and P... in case you find it valuable for your efforts. The saml piece was developed specifically to work with our saml provider (which supports Kerberos authentication), but the overall process for authentication to the identity provider (SAML) with handing the saml code back to the portal to acquire an access and refresh token is technically feasible.
Best of luck.
Here is a relevant post: Python API can't connect to portal with windows authentication
And another: How to connect to my Portal when our security is ADFS?
And one more for good measure: https://community.esri.com/thread/188253-connect-to-portal-with-iwa
Let me know if any of those isolate the issue!