Skip to content

Commit

Permalink
Tolerate ID token time errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rayluo committed Jan 29, 2024
1 parent ba3cec0 commit 386ea2e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
9 changes: 9 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,12 @@ New in MSAL Python 1.26

.. automethod:: __init__


Exceptions
----------
These are exceptions that MSAL Python may raise.
You should not need to create them directly.
You may want to catch them to provide a better error message to your end users.

.. autoclass:: msal.IdTokenError

3 changes: 1 addition & 2 deletions msal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
ConfidentialClientApplication,
PublicClientApplication,
)
from .oauth2cli.oidc import Prompt
from .oauth2cli.oidc import Prompt, IdTokenError
from .token_cache import TokenCache, SerializableTokenCache
from .auth_scheme import PopAuthScheme

5 changes: 3 additions & 2 deletions tests/test_oidc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from tests import unittest

import oauth2cli
import msal
from msal import oauth2cli


class TestIdToken(unittest.TestCase):
Expand All @@ -16,6 +17,6 @@ def test_id_token_should_tolerate_time_error(self):
}, "id_token is decoded correctly, without raising exception")

def test_id_token_should_error_out_on_client_id_error(self):
with self.assertRaises(oauth2cli.IdTokenError):
with self.assertRaises(msal.IdTokenError):
oauth2cli.oidc.decode_id_token(self.EXPIRED_ID_TOKEN, client_id="not foo")

0 comments on commit 386ea2e

Please sign in to comment.