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.5.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.5.0
File Size Uploaded Provenance Actions
ms_entrance-1.5.0.tar.gz 23.2 kB Without provenance Details for ms_entrance-1.5.0.tar.gz

Built distribution (wheel)

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

Total release size: 50.4 kB

Release files / ms_entrance-1.5.0.tar.gz

Download URL ms_entrance-1.5.0.tar.gz
Size 23.2 kB
Tags Source
SHA-256 checksum
How to use checksums
043833236b4986a8ec5ecd9346a10b4029c79b44e4bb73a6412c548a9d1b7940
BLAKE2b-256 checksum
How to use checksums
cfe448b023b0a9acef1ade0be84d6e10313e084201f34269e5e8ac4b86d5bc2e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","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.5.0-py3-none-any.whl

Download URL ms_entrance-1.5.0-py3-none-any.whl
Size 27.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
90a369325917e9f0f03f84210db4c6cf35ced9a1d92e691e9201e38a38eff341
BLAKE2b-256 checksum
How to use checksums
35d5e0a27061ebaba7d9cd2128a2528eec68f8ffd1c49785730f4597da1d67c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","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.5.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