aiohttp-msal 0.6.4__py3-none-any.whl → 0.6.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
aiohttp_msal/__init__.py CHANGED
@@ -13,7 +13,7 @@ from .settings import ENV
13
13
 
14
14
  _LOGGER = logging.getLogger(__name__)
15
15
 
16
- VERSION = "0.6.4"
16
+ VERSION = "0.6.5"
17
17
 
18
18
 
19
19
  def msal_session(*args: Callable[[AsyncMSAL], Union[Any, Awaitable[Any]]]) -> Callable:
@@ -23,7 +23,7 @@ HTTP_PATCH = "patch"
23
23
  HTTP_DELETE = "delete"
24
24
  HTTP_ALLOWED = [HTTP_GET, HTTP_POST, HTTP_PUT, HTTP_PATCH, HTTP_DELETE]
25
25
 
26
- MY_SCOPE = ["User.Read", "User.Read.All"]
26
+ DEFAULT_SCOPES = ["User.Read", "User.Read.All"]
27
27
 
28
28
 
29
29
  def async_wrap(func: Callable) -> Callable:
@@ -148,12 +148,14 @@ class AsyncMSAL:
148
148
  if hasattr(self, "save_token_cache"):
149
149
  self.save_token_cache(self.token_cache)
150
150
 
151
- def build_auth_code_flow(self, redirect_uri: str) -> str:
151
+ def build_auth_code_flow(
152
+ self, redirect_uri: str, scopes: Optional[list[str]] = None
153
+ ) -> str:
152
154
  """First step - Start the flow."""
153
155
  self.session[TOKEN_CACHE] = None # type: ignore
154
156
  self.session[USER_EMAIL] = None # type: ignore
155
157
  self.session[FLOW_CACHE] = res = self.app.initiate_auth_code_flow(
156
- MY_SCOPE,
158
+ scopes or DEFAULT_SCOPES,
157
159
  redirect_uri=redirect_uri,
158
160
  response_mode="form_post"
159
161
  # max_age=1209600,
@@ -183,11 +185,13 @@ class AsyncMSAL:
183
185
  None, self.acquire_token_by_auth_code_flow, auth_response
184
186
  )
185
187
 
186
- def get_token(self) -> Optional[dict[str, Any]]:
188
+ def get_token(self, scopes: Optional[list[str]] = None) -> Optional[dict[str, Any]]:
187
189
  """Acquire a token based on username."""
188
190
  accounts = self.app.get_accounts()
189
191
  if accounts:
190
- result = self.app.acquire_token_silent(scopes=MY_SCOPE, account=accounts[0])
192
+ result = self.app.acquire_token_silent(
193
+ scopes=scopes or DEFAULT_SCOPES, account=accounts[0]
194
+ )
191
195
  self._save_token_cache()
192
196
  return result
193
197
  return None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aiohttp-msal
3
- Version: 0.6.4
3
+ Version: 0.6.5
4
4
  Summary: Helper Library to use the Microsoft Authentication Library (MSAL) with aiohttp
5
5
  Home-page: https://github.com/kellerza/aiohttp_msal
6
6
  Author: Johann Kellerman
@@ -1,5 +1,5 @@
1
- aiohttp_msal/__init__.py,sha256=78mjldM51U-GlDF4XnAqMJKEsUveWQSknwKPazzXv3o,3001
2
- aiohttp_msal/msal_async.py,sha256=lyiNFS8iJpg2WTwOz7ogmrTwN3WYaRQXos9hYiPLLwI,9798
1
+ aiohttp_msal/__init__.py,sha256=hz7_nNDPT3bWxWu78vjAAWr9i60eRX0He34RRZ6DIz0,3001
2
+ aiohttp_msal/msal_async.py,sha256=Z810J2OHn7H4EevfQ7XB5L7Rks8iB4RsdFbFv5wPb3k,9952
3
3
  aiohttp_msal/redis_tools.py,sha256=eEYGJTCWtpyBvmI7IAs2jInypsyzbQP_RAVQnAyRgtE,3737
4
4
  aiohttp_msal/routes.py,sha256=c-w5wHaLAYGEqZvfZ8PnzzRh60asLqdUa30lvSANdYM,8319
5
5
  aiohttp_msal/settings.py,sha256=ZZn7D6QmIyQSvuqCAoTacKRXYfopqK4P74eVdPCw-uI,1231
@@ -9,9 +9,9 @@ tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  tests/test_init.py,sha256=sHmt7yNDlcu5JHrpM_gim0NeLce0NwUAMM3HAdGoo58,75
10
10
  tests/test_msal_async.py,sha256=31MCoAbUiyUhc4SkebUKpjLDHozEBko-QgEBSHjfSoM,332
11
11
  tests/test_settings.py,sha256=z-qtUs1zl5Q9NEux051eebyPnArLZ_OfZu65FKz0N4Y,333
12
- aiohttp_msal-0.6.4.dist-info/LICENSE,sha256=H1aGfkSfZFwK3q4INn9mUldOJGZy-ZXu5-65K9Glunw,1080
13
- aiohttp_msal-0.6.4.dist-info/METADATA,sha256=67u7FqAWttPQktDdb20TQyxIsv-zDEXcmOFmdDILcmk,4565
14
- aiohttp_msal-0.6.4.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
15
- aiohttp_msal-0.6.4.dist-info/top_level.txt,sha256=QPWOi5JtacVEdbaU5bJExc9o-cCT2Lufx0QhUpsv5_E,19
16
- aiohttp_msal-0.6.4.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
17
- aiohttp_msal-0.6.4.dist-info/RECORD,,
12
+ aiohttp_msal-0.6.5.dist-info/LICENSE,sha256=H1aGfkSfZFwK3q4INn9mUldOJGZy-ZXu5-65K9Glunw,1080
13
+ aiohttp_msal-0.6.5.dist-info/METADATA,sha256=xXoce4L-2TzT6OufblyHIsHoWYIrrsa3Qarxfi3KOT0,4565
14
+ aiohttp_msal-0.6.5.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
15
+ aiohttp_msal-0.6.5.dist-info/top_level.txt,sha256=QPWOi5JtacVEdbaU5bJExc9o-cCT2Lufx0QhUpsv5_E,19
16
+ aiohttp_msal-0.6.5.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
17
+ aiohttp_msal-0.6.5.dist-info/RECORD,,