"""Adapt CIMD method negotiation for DOT's public-client-only implementation.""" from oauth2_provider.cimd import SafeMetadataFetcher from oauth2_provider.settings import oauth2_settings class CompatibleCIMDFetcher(SafeMetadataFetcher): def fetch(self, client_id): metadata, max_age = super().fetch(client_id) methods = metadata.get('token_endpoint_auth_methods_supported') if ( metadata.get('token_endpoint_auth_method') != 'none' and isinstance(methods, list) and 'none' in methods and 'none' in oauth2_settings.OAUTH2_TOKEN_ENDPOINT_AUTH_METHODS_SUPPORTED ): # DOT 3.4 accepts only public CIMD clients. The plural metadata # field explicitly allows this method even when the legacy singular # field prefers private_key_jwt, which this server does not offer. metadata = {**metadata, 'token_endpoint_auth_method': 'none'} return metadata, max_age