Documentation https://django-ninja.dev/guides/authentication/ suggests setting auth=GlobalAuth() on NinjaAPI initialization for having authentication setting across endpoints without issuing it separately for every time.
Copying the example code here:
from ninja import NinjaAPI, Form
from ninja.security import HttpBearer
class GlobalAuth(HttpBearer):
def authenticate(self, request, token):
if token == "supersecret":
return token
api = NinjaAPI(auth=GlobalAuth())
Not sure about the implications supporting this would have but for now I'll leave the helper for a moment and try import django-ninja directly (as mentioned in nanodjango docs).
Documentation https://django-ninja.dev/guides/authentication/ suggests setting
auth=GlobalAuth()
onNinjaAPI
initialization for having authentication setting across endpoints without issuing it separately for every time.Copying the example code here:
I couldn't find a way to do this while using the ninja helper which initializes
NinjaAPI
without parameters at: https://github.com/radiac/nanodjango/blob/612abf5d8915a47585e4447c46b4d4efb7bbd50f/nanodjango/app.py#L300Not sure about the implications supporting this would have but for now I'll leave the helper for a moment and try import
django-ninja
directly (as mentioned in nanodjango docs).