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
  • 🧩 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.3.1

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.3.1
File Size Uploaded Provenance
ms_entrance-1.3.1.tar.gz 20.8 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 44.7 kB

Release files / ms_entrance-1.3.1.tar.gz

Download URL ms_entrance-1.3.1.tar.gz
Size 20.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4635bc591a69cdd8e3ed35ebec1d9a00e627011d12e913b06a47439ecd864b9b
BLAKE2b-256 checksum
How to use checksums
536560be0ecf0b8df66ae92454c3e07ea077b63df16d9eea8206e48c02e56ba0
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.1-py3-none-any.whl

Download URL ms_entrance-1.3.1-py3-none-any.whl
Size 23.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cb15cc3b31de9bf49c2867d80cc30fce8f70f6f1aa325a5fab24ac6ab7ca818a
BLAKE2b-256 checksum
How to use checksums
075b121336a2b4cb8f9b9cf6b74dd94c2f3741b874552376b010d0e39d9d8c0a
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.1

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