Skip to content

Commit 1318025

Browse files
authored
Merge pull request #581 from AzureAD/release-1.23.0
MSAL Python 1.23.0
2 parents dabc08c + 44c3bfb commit 1318025

13 files changed

+171
-100
lines changed

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
runs-on: ubuntu-latest # It switched to 22.04 shortly after 2022-Nov-8
2727
strategy:
2828
matrix:
29-
python-version: [2.7, 3.7, 3.8, 3.9, "3.10", "3.11", "3.12-dev"]
29+
python-version: [3.7, 3.8, 3.9, "3.10", "3.11", "3.12-dev"]
3030

3131
steps:
3232
- uses: actions/checkout@v2

docs/index.rst

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
MSAL Python documentation
1+
MSAL Python Documentation
22
=========================
33

44
.. toctree::
55
:maxdepth: 2
66
:caption: Contents:
77
:hidden:
88

9-
MSAL Documentation <https://docs.microsoft.com/en-au/azure/active-directory/develop/msal-authentication-flows>
10-
GitHub Repository <https://github.com/AzureAD/microsoft-authentication-library-for-python>
9+
index
10+
11+
..
12+
Comment: Perhaps because of the theme, only the first level sections will show in TOC,
13+
regardless of maxdepth setting.
1114
1215
You can find high level conceptual documentations in the project
1316
`README <https://github.com/AzureAD/microsoft-authentication-library-for-python>`_.
@@ -58,8 +61,8 @@ MSAL Python supports some of them.
5861
<https://github.com/AzureAD/microsoft-authentication-library-for-python/tree/dev/sample>`_.
5962

6063

61-
API
62-
===
64+
API Reference
65+
=============
6366

6467
The following section is the API Reference of MSAL Python.
6568
The API Reference is like a dictionary. You **read this API section when and only when**:
@@ -88,26 +91,32 @@ MSAL proposes a clean separation between
8891
They are implemented as two separated classes,
8992
with different methods for different authentication scenarios.
9093

94+
ClientApplication
95+
=================
96+
97+
.. autoclass:: msal.ClientApplication
98+
:members:
99+
:inherited-members:
100+
101+
.. automethod:: __init__
102+
91103
PublicClientApplication
92-
-----------------------
104+
=======================
93105

94106
.. autoclass:: msal.PublicClientApplication
95107
:members:
96-
:inherited-members:
97108

98109
.. automethod:: __init__
99110

100111
ConfidentialClientApplication
101-
-----------------------------
112+
=============================
102113

103114
.. autoclass:: msal.ConfidentialClientApplication
104115
:members:
105-
:inherited-members:
106116

107-
.. automethod:: __init__
108117

109118
TokenCache
110-
----------
119+
==========
111120

112121
One of the parameters accepted by
113122
both `PublicClientApplication` and `ConfidentialClientApplication`

msal/application.py

Lines changed: 96 additions & 40 deletions
Large diffs are not rendered by default.

msal/oauth2cli/http.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ class Response(object):
5858
# but a `text` would be more generic,
5959
# when downstream packages would potentially access some XML endpoints.
6060

61+
headers = {} # Duplicated headers are expected to be combined into one header
62+
# with its value as a comma-separated string.
63+
# https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.2
64+
# Popular HTTP libraries model it as a case-insensitive dict.
65+
6166
def raise_for_status(self):
6267
"""Raise an exception when http response status contains error"""
6368
raise NotImplementedError("Your implementation should provide this")

msal/token_cache.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ def find(self, credential_type, target=None, query=None):
102102
]
103103

104104
def add(self, event, now=None):
105-
# type: (dict) -> None
106105
"""Handle a token obtaining event, and add tokens into cache."""
107106
def make_clean_copy(dictionary, sensitive_fields): # Masks sensitive info
108107
return {

sample/confidential_client_certificate_sample.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,9 @@
5151
# https://msal-python.readthedocs.io/en/latest/#msal.SerializableTokenCache
5252
)
5353

54-
# The pattern to acquire a token looks like this.
55-
result = None
56-
57-
# Firstly, looks up a token from cache
58-
# Since we are looking for token for the current app, NOT for an end user,
59-
# notice we give account parameter as None.
60-
result = app.acquire_token_silent(config["scope"], account=None)
61-
62-
if not result:
63-
logging.info("No suitable token exists in cache. Let's get a new one from AAD.")
64-
result = app.acquire_token_for_client(scopes=config["scope"])
54+
# Since MSAL 1.23, acquire_token_for_client(...) will automatically look up
55+
# a token from cache, and fall back to acquire a fresh token when needed.
56+
result = app.acquire_token_for_client(scopes=config["scope"])
6557

6658
if "access_token" in result:
6759
# Calling graph using the access token

sample/confidential_client_secret_sample.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,9 @@
5050
# https://msal-python.readthedocs.io/en/latest/#msal.SerializableTokenCache
5151
)
5252

53-
# The pattern to acquire a token looks like this.
54-
result = None
55-
56-
# Firstly, looks up a token from cache
57-
# Since we are looking for token for the current app, NOT for an end user,
58-
# notice we give account parameter as None.
59-
result = app.acquire_token_silent(config["scope"], account=None)
60-
61-
if not result:
62-
logging.info("No suitable token exists in cache. Let's get a new one from AAD.")
63-
result = app.acquire_token_for_client(scopes=config["scope"])
53+
# Since MSAL 1.23, acquire_token_for_client(...) will automatically look up
54+
# a token from cache, and fall back to acquire a fresh token when needed.
55+
result = app.acquire_token_for_client(scopes=config["scope"])
6456

6557
if "access_token" in result:
6658
# Calling graph using the access token

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ universal=1
55
project_urls =
66
Changelog = https://github.com/AzureAD/microsoft-authentication-library-for-python/releases
77
Documentation = https://msal-python.readthedocs.io/
8-
Questions = https://stackoverflow.com/questions/tagged/msal+python
8+
Questions = https://stackoverflow.com/questions/tagged/azure-ad-msal+python
99
Feature/Bug Tracker = https://github.com/AzureAD/microsoft-authentication-library-for-python/issues

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
'requests>=2.0.0,<3',
7878
'PyJWT[crypto]>=1.0.0,<3', # MSAL does not use jwt.decode(), therefore is insusceptible to CVE-2022-29217 so no need to bump to PyJWT 2.4+
7979

80-
'cryptography>=0.6,<43',
80+
'cryptography>=0.6,<44',
8181
# load_pem_private_key() is available since 0.6
8282
# https://github.com/pyca/cryptography/blob/master/CHANGELOG.rst#06---2014-09-29
8383
#

tests/http_client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ def close(self): # Not required, but we use it to avoid a warning in unit test
2525

2626

2727
class MinimalResponse(object): # Not for production use
28-
def __init__(self, requests_resp=None, status_code=None, text=None):
28+
def __init__(self, requests_resp=None, status_code=None, text=None, headers=None):
2929
self.status_code = status_code or requests_resp.status_code
30-
self.text = text or requests_resp.text
30+
self.text = text if text is not None else requests_resp.text
31+
self.headers = {} if headers is None else headers
3132
self._raw_resp = requests_resp
3233

3334
def raise_for_status(self):

0 commit comments

Comments
 (0)