diff --git a/api/config/schema.py b/api/config/schema.py index a78a96a89..bfdeea26f 100644 --- a/api/config/schema.py +++ b/api/config/schema.py @@ -1,4 +1,5 @@ from drf_spectacular.contrib.django_oauth_toolkit import OpenApiAuthenticationExtension +from drf_spectacular.plumbing import build_bearer_security_scheme_object import os @@ -28,6 +29,17 @@ class CustomOAuthExt(OpenApiAuthenticationExtension): return {"type": "oauth2", "flows": flows} +class CustomApplicationTokenExt(OpenApiAuthenticationExtension): + target_class = "funkwhale_api.common.authentication.ApplicationTokenAuthentication" + name = "ApplicationToken" + + def get_security_definition(self, auto_schema): + return build_bearer_security_scheme_object( + header_name='Authorization', + token_prefix='Bearer', + ) + + def custom_preprocessing_hook(endpoints): filtered = [] # your modifications to the list of operations that are exposed in the schema