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
10
10
### Added
11
11
12
12
- ` 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 ) )
13
14
14
15
### Changed
15
16
Original file line number Diff line number Diff line change @@ -268,9 +268,12 @@ def __init__(
268
268
raise ValueError ("At least `issuer` or `discovery_url` should be specified" )
269
269
if not requests_session :
270
270
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
274
277
self .issuer = issuer or self .config ["issuer" ]
275
278
# Minimal set of scopes to request
276
279
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
238
238
assert p .get_scopes_string () == "openid"
239
239
240
240
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
+
241
250
def test_oidc_client_info_uses_device_flow_pkce_support (requests_mock ):
242
251
oidc_issuer = "https://oidc.test"
243
252
oidc_mock = OidcMock (
You can’t perform that action at this time.
0 commit comments