🎭 Extract Microsoft OAuth tokens using Playwright browser automation.
Project description
🎭 Extract Microsoft OAuth tokens using Playwright browser automation.
📦 Installation
To install msauth-browser, you can use pip, pip3 or pipx. Either from pypi repository or from GitHub source. Prefer using pipx, since it install Python applications in isolated virtual environments.
From PyPI
pipx install msauth-browser
pip install msauth-browser
From GitHub
pip install "git+https://github.com/n3rada/msauth-browser"
pipx install "git+https://github.com/n3rada/msauth-browser"
Playwright
Ensure chromium playwright browser is available:
playwright install chromium
If installed with pipx:
- Windows PowerShell
$env:NODE_TLS_REJECT_UNAUTHORIZED = "0"
& "$env:USERPROFILE\pipx\venvs\msauth-browser\Scripts\playwright.exe" install chromium
Usage
msauth-browser
Options:
--prt-cookie <JWT>: Use anx-ms-RefreshTokenCredentialPRT cookie for SSO-based login.--headless: Run Playwright in headless mode.
msauth-browser --headless --prt-cookie "<x-ms-RefreshTokenCredential>"
About the PRT Cookie
The PRT cookie is officially x-ms-RefreshTokenCredential and it is a JSON Web Token (JWT). The actual Primary Refresh Token (PRT) is encapsulated within the refresh_token, which is encrypted by a key under the control of Entra ID, rendering its contents opaque.
It can be used as a cookie wired to login.microsoftonline.com domain in order to use-it to authenticate to the service while skiping credential prompts.
Microsoft first-party apps
Microsoft first-party apps have hardcoded, pre-approved scopes.
You cannot simply add ChannelMessage.Read.All to the scope parameter of the Teams application, the request will fail.
Why not microsoft-authentication-library-for-python (MSAL)?
One major limitation is that it requires localhost redirect URIs.
It also does not support integrating PRT cookies.
Adding new app presets
- Drop a JSON file into
msauth_browser/configs/. - Provide the required fields:
nameclient_idredirect_uridefault_scopes(array of scopes) — optional; if omitted or empty, the tool defaults toopenidandoffline_access.
- Optionally include a
slugfield; otherwise the filename (without extension) becomes the lookup key.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file msauth_browser-0.2.1.tar.gz.
File metadata
- Download URL: msauth_browser-0.2.1.tar.gz
- Upload date:
- Size: 21.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.13.9 Linux/6.16.8+kali-amd64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a460e530eb71efdc739c6d483d4b1db399cc30dc5a5ecbf99a6b023fcb9a24bb
|
|
| MD5 |
877e65d57f413e0b7c92d55e4c36ddf1
|
|
| BLAKE2b-256 |
59e85c06e9bab691817b0c91456d28a8989c966b3a0e861c2b0c888dcd3c6b14
|
File details
Details for the file msauth_browser-0.2.1-py3-none-any.whl.
File metadata
- Download URL: msauth_browser-0.2.1-py3-none-any.whl
- Upload date:
- Size: 24.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.13.9 Linux/6.16.8+kali-amd64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83a63119bf003cade1fdc4351a486b07e700c4c00fb431d38ba20c666d9b0cff
|
|
| MD5 |
d7cfc08e5a1f11b72e7851db77466e6a
|
|
| BLAKE2b-256 |
8e1f3bdaafe1166ff0d57d865d7be911acb93818ac583b8b61e645cb2c76ba65
|