Skip to content

Commit 4f957d6

Browse files
authored
[SSH] Serialize AT token_type and expose in result (#95)
1 parent e4510a3 commit 4f957d6

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

msal/application.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ def _acquire_token_silent_from_cache_and_possibly_refresh_it(
441441
logger.debug("Cache hit an AT")
442442
return { # Mimic a real response
443443
"access_token": entry["secret"],
444-
"token_type": "Bearer",
444+
"token_type": entry.get("token_type", "Bearer"),
445445
"expires_in": int(expires_in), # OAuth2 specs defines it as int
446446
}
447447
return self._acquire_token_silent_by_finding_rt_belongs_to_me_or_my_family(

msal/token_cache.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ def __add(self, event, now=None):
160160
"client_id": event.get("client_id"),
161161
"target": target,
162162
"realm": realm,
163+
"token_type": response.get("token_type", "Bearer"),
163164
"cached_at": str(now), # Schema defines it as a string
164165
"expires_on": str(now + expires_in), # Same here
165166
"extended_expires_on": str(now + ext_expires_in) # Same here

tests/test_token_cache.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def testAddByAad(self):
8383
'realm': 'contoso',
8484
'secret': 'an access token',
8585
'target': 's2 s1 s3',
86+
'token_type': 'some type',
8687
},
8788
self.cache._cache["AccessToken"].get(
8889
'uid.utid-login.example.com-accesstoken-my_client_id-contoso-s2 s1 s3')
@@ -155,6 +156,7 @@ def testAddByAdfs(self):
155156
'realm': 'adfs',
156157
'secret': 'an access token',
157158
'target': 's2 s1 s3',
159+
'token_type': 'some type',
158160
},
159161
self.cache._cache["AccessToken"].get(
160162
'subject-fs.msidlab8.com-accesstoken-my_client_id-adfs-s2 s1 s3')

0 commit comments

Comments
 (0)