File tree Expand file tree Collapse file tree 3 files changed +16
-3
lines changed
Expand file tree Collapse file tree 3 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010### Added
1111
1212- ` sar_backscatter ` : try to retrieve coefficient options from backend ([ #693 ] ( https://github.com/Open-EO/openeo-python-client/issues/693 ) )
13+ - Improve error message when OIDC provider is unavailable ([ #751 ] ( https://github.com/Open-EO/openeo-python-client/issues/751 ) )
1314
1415### Changed
1516
Original file line number Diff line number Diff line change @@ -268,9 +268,12 @@ def __init__(
268268 raise ValueError ("At least `issuer` or `discovery_url` should be specified" )
269269 if not requests_session :
270270 requests_session = requests .Session ()
271- discovery_resp = requests_session .get (self .discovery_url , timeout = 20 )
272- discovery_resp .raise_for_status ()
273- self .config = discovery_resp .json ()
271+ try :
272+ discovery_resp = requests_session .get (self .discovery_url , timeout = 20 )
273+ discovery_resp .raise_for_status ()
274+ self .config = discovery_resp .json ()
275+ except Exception as e :
276+ raise OidcException (f"Failed to obtain OIDC discovery document from { self .discovery_url !r} : { e !r} " ) from e
274277 self .issuer = issuer or self .config ["issuer" ]
275278 # Minimal set of scopes to request
276279 self ._supported_scopes = self .config .get ("scopes_supported" , ["openid" ])
Original file line number Diff line number Diff line change @@ -238,6 +238,15 @@ def test_provider_info_get_scopes_string_refresh_token_offline_access(requests_m
238238 assert p .get_scopes_string () == "openid"
239239
240240
241+ def test_provider_info_issuer_broken_json (requests_mock ):
242+ requests_mock .get ("https://authit.test/.well-known/openid-configuration" , text = "<marquee>nope!</marquee>" )
243+ with pytest .raises (
244+ OidcException ,
245+ match = "Failed to obtain OIDC discovery document from 'https://authit.test/.well-known/openid-configuration': JSONDecodeError" ,
246+ ):
247+ OidcProviderInfo (issuer = "https://authit.test" )
248+
249+
241250def test_oidc_client_info_uses_device_flow_pkce_support (requests_mock ):
242251 oidc_issuer = "https://oidc.test"
243252 oidc_mock = OidcMock (
You can’t perform that action at this time.
0 commit comments