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
  • 🔢 Number-matching push - push_login() drives an Authenticator push headlessly and streams out the two-digit number to tap, so your own UI can show "tap 42"
  • 🙋 Browser fallback - interactive=True opens the real browser for what headless can't do (passkeys, an unhandled challenge), 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
  • Number-matching push - push_login(): capture the tap number server-side for your own UI
  • 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.6.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.6.0
File Size Uploaded Provenance Actions
ms_entrance-1.6.0.tar.gz 26.9 kB Without provenance Details for ms_entrance-1.6.0.tar.gz

Built distribution (wheel)

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

Total release size: 58.4 kB

Release files / ms_entrance-1.6.0.tar.gz

Download URL ms_entrance-1.6.0.tar.gz
Size 26.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ebe535c20cbc2a4505c4f3b31decb1036ee75dd6c2a7a0c6b3b12a12e1ceb6cd
BLAKE2b-256 checksum
How to use checksums
ee76e179cff5f72a6362d0515b0f96d48e29cdfe6125e4007df99daee27db6eb
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.6.0-py3-none-any.whl

Download URL ms_entrance-1.6.0-py3-none-any.whl
Size 31.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cd3f91572b7e8125077b0bbbc9ef9006b1a88586a48facdda212a9c85d4af3e8
BLAKE2b-256 checksum
How to use checksums
e5f292ad549f1a9e98308326f8498362c92963c65039f8624ef3f78ddda1e4d7
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.6.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