Skip to main content

Microsoft Azure AD authentication helper for CLI applications

Project description

Helper to authenticate against Microsoft Azure AD and store the resulting tokens for commandline applications.

Usage

  1. Run interactively to store a refresh token in the cache

  2. Use in e.g. automated tests to retrieve an ID token from the cache (which automatically refreshes it if necessary).

$ msal-token --client-id=myclient --client-secret=mysecret \
    --cache-url=file:///tmp/msal.json login
Please visit https://login.microsoftonline.com/...
# Perform login via browser


def test_protected_web_ui():
    auth = zeit.msal.Authenticator(
        'myclient', 'mysecret', 'file:///tmp/msal.json')
    http = requests.Session()
    http.headers['Authorization'] = 'Bearer %s' % auth.get_id_token()
    r = http.get('https://example.zeit.de/')
    assert r.status_code == 200

Alternatively, retrieve the refresh token after interactive login, and use that in tests:

auth.login_with_refresh_token('myrefreshtoken')

1.3.1 (2025-02-18)

Changes

  • Update to non-deprecated msal search API (msal)

zeit.msal changes

1.4.0 (unreleased)

  • Nothing changed yet.

1.3.0 (2025-02-17)

  • Update to current msal API when requesting an ID token

1.2.1 (2024-03-28)

  • Dilligently close file handles

1.2.0 (2024-03-21)

  • Preserve query parameters in redis url

1.1.0 (2021-07-28)

  • Add get_access_token method, make scopes configurable

  • Implement redis cache

1.0.0 (2021-07-23)

  • Initial release

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

zeit_msal-1.3.1.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zeit_msal-1.3.1-py2.py3-none-any.whl (6.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file zeit_msal-1.3.1.tar.gz.

File metadata

  • Download URL: zeit_msal-1.3.1.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for zeit_msal-1.3.1.tar.gz
Algorithm Hash digest
SHA256 9fea5429606d0fc15628b6c0cd1b080392b490f6f3bd208f9c1a8e17e9e05a70
MD5 ef2a25185ae686e8583b21f55be590c0
BLAKE2b-256 0419a5e7c770609e98aedfbf646b37b80f0a2356f110ad455fdc79949d81d9e8

See more details on using hashes here.

File details

Details for the file zeit_msal-1.3.1-py2.py3-none-any.whl.

File metadata

  • Download URL: zeit_msal-1.3.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for zeit_msal-1.3.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1cab5fe843e2f8dc75f30691579aa1c6dab9195221dedd42723322465705d021
MD5 f704324fca98d41915ee7e3a4c2a7514
BLAKE2b-256 a94b1964d284723b9e2925e8f2f9cea8a971408dd6a378d18d47e99749a5588a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page