Skip to main content

Entrance

Entrance Logo

Your headless entrance to Microsoft Entra.
Browser-grade OAuth login for any Microsoft-federated provider - without a browser.

visits Python 3.10+ No browser MIT license


What is Entrance?

Plenty of services hand you an OAuth "open this URL in a browser to log in" link and federate the actual authentication to Microsoft Entra. entrance walks that flow for you over pure HTTP - no Playwright, no headless Chromium, no Selenium - and hands back the authorization code (or exchanged tokens). Point it at any authorize URL that ends up at login.microsoftonline.com and it logs in, handles MFA, and returns.

The whole thing is one small module and two dependencies.

Features

  • 🚪 No browser - pure HTTP, drives login.microsoftonline.com directly
  • 🌐 Provider-agnostic - give it any OAuth2 authorize URL federated to Entra
  • 🔐 Headless MFA - TOTP second factor solved automatically from your authenticator secret
  • 🙋 Browser fallback - interactive=True opens the real browser for what headless can't do (push / number-matching MFA, passkeys), catching the code via a localhost server or copy-paste
  • 🔑 Mint & enroll TOTP - new_totp() generates a software token, enroll_totp() registers a brand-new one on the account, so every later login is fully headless
  • 🔢 Device code sign-in - device_login() / foci_login(device=True): show a short code, the user enters it at a URL - no redirect, no loopback, no copy-paste
  • 🧩 FOCI broker - foci_login() turns one sign-in into tokens for any pre-consented first-party client / scope, persisted for password-free reruns
  • 🍪 Silent SSO - persisted cookie jar means password-free reruns
  • 📦 Tiny - one core module, curl_cffi + pyotp

Install

pip install ms-entrance        # or: uv add ms-entrance

The import name is entrance (from entrance import login). Python 3.10+; curl_cffi and pyotp are pulled in automatically.

Quickstart

from entrance import login

res = login(
    "https://provider.example/authorize?client_id=...&state=...&code_challenge=...",
    username="you@school.ch",
    password="...",
    totp_secret="JBSWY3DPEHPK3PXP",   # optional - only if the account has TOTP MFA
)
print(res["code"])           # the authorization code (intercepted at the callback)
print(res["callback_url"])   # the full callback URL - built, NOT sent

Docs

  • login() - MFA, token exchange, ms_redirect, cookies, return value, how it works
  • Browser fallback - interactive=True / browser_login() (loopback + paste)
  • TOTP devices - new_totp() and headless enroll_totp()
  • FOCI broker - foci_login() / Broker for Microsoft first-party clients

Disclaimer

Entrance is published for educational and research purposes only - to document how OAuth2 / OpenID Connect authorization-code + PKCE flows behave when federated through Microsoft Entra, and how a browserless client negotiates them.

Use it only against accounts you own, or with the explicit authorization of the account or tenant owner. You alone are responsible for your use of it and for complying with Microsoft's terms, your identity provider's terms, your institution's acceptable-use policy, and applicable law. Automating logins to accounts you do not own, evading access controls, or circumventing MFA you were not granted is not the intended use. The software is provided "as is", without warranty of any kind, and the author accepts no liability for misuse. Not affiliated with or endorsed by Microsoft.

License

MIT (c) PianoNic

Metadata

Release files for ms-entrance 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ms-entrance 1.4.0
File Size Uploaded Provenance
ms_entrance-1.4.0.tar.gz 22.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ms-entrance 1.4.0
File Interpreter ABI Platform
ms_entrance-1.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 48.4 kB

Release files / ms_entrance-1.4.0.tar.gz

Download URL ms_entrance-1.4.0.tar.gz
Size 22.3 kB
Tags Source
SHA-256 checksum
How to use checksums
77fdddc2a5c35a137ff32d5afebe71221c5024ec0f6902bd54e9b01f558922e0
BLAKE2b-256 checksum
How to use checksums
22f7583e81c54014b408f8595781b07f33c871901a80b2512cc5a3ef9acf3a16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ms_entrance-1.4.0-py3-none-any.whl

Download URL ms_entrance-1.4.0-py3-none-any.whl
Size 26.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f2909924a54c822a78f1b9657bfda4645c003fda06e6c285450827421711bc0b
BLAKE2b-256 checksum
How to use checksums
189b94ea393cd04e8e31612dd5f9d52c52bed42e5ede20ac58ab450559cbb40d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for ms-entrance 1.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page