From 911b28554b73118ff8f0608c32510de04eb8a5f1 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Fri, 11 Nov 2022 10:24:05 -0500 Subject: [PATCH] Detect oauth2 even if there's no authorize_uri As long as we have a JWT and there's a token_uri, we can talk oauth2. --- fhirclient/auth.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fhirclient/auth.py b/fhirclient/auth.py index af77c27c3..0127ff980 100644 --- a/fhirclient/auth.py +++ b/fhirclient/auth.py @@ -44,7 +44,6 @@ def from_capability_security(cls, security, state=None): state['token_uri'] = ee.valueUri elif 'authorize' == ee.url: state['authorize_uri'] = ee.valueUri - auth_type = 'oauth2' elif 'register' == ee.url: state['registration_uri'] = ee.valueUri break @@ -56,9 +55,11 @@ def from_capability_security(cls, security, state=None): state['registration_uri'] = e.valueUri elif "http://fhir-registry.smarthealthit.org/StructureDefinition/oauth-uris#authorize" == e.url: state['authorize_uri'] = e.valueUri - auth_type = 'oauth2' elif "http://fhir-registry.smarthealthit.org/StructureDefinition/oauth-uris#token" == e.url: state['token_uri'] = e.valueUri + + if 'authorize_uri' in state or ('token_uri' in state and 'jwt_token' in state): + auth_type = 'oauth2' return cls.create(auth_type, state=state)