Entrance
Your headless entrance to Microsoft Entra.
Browser-grade OAuth login for any Microsoft-federated provider - without a browser.
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.comdirectly - 🌐 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=Trueopens 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 - 🧩 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 headlessenroll_totp() - FOCI broker -
foci_login()/Brokerfor 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
Metadata
Release files for ms-entrance 1.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| ms_entrance-1.3.2.tar.gz | 20.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ms_entrance-1.3.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 44.8 kB
Release files / ms_entrance-1.3.2.tar.gz
| Download URL | ms_entrance-1.3.2.tar.gz |
|---|---|
| Size | 20.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
042abfe105e0fd02f5635657e5b98eb9ea547d70ab7ef4396144c165e86dfa5b
|
|
BLAKE2b-256 checksum How to use checksums |
cb2377c9298d750c9a7ecf805c9db1750f4faffaf1f82ddca6f346a14a9c4fd1
|
| 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.3.2-py3-none-any.whl
| Download URL | ms_entrance-1.3.2-py3-none-any.whl |
|---|---|
| Size | 23.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a4cc911daef2bd46505c2536151ab1b087b532f010920f9687676661c92d539a
|
|
BLAKE2b-256 checksum How to use checksums |
f69cfa6c0094163d42b9693fa8c2406496742a9ca873271ae4de7aecf7f9f461
|
| 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.3.2
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.