-
Notifications
You must be signed in to change notification settings - Fork 106
Open
Labels
docsRequest for documentationRequest for documentation
Description
Hi,
I have a requirement to change the Api-Key name, but I can't get it to work. I'm not that great of a developer ;)
Running djangorestframework-api-key 2.3.0 for a new project, and getting started with Api keys. I have to support a remote client that needs to send me a header in the format "Authorization: API-KEY ", so I need to change Api-Key to API-KEY.
The documentation however, doesn't seem to work:
from rest_framework_api_key.models import HasAPIKey
from rest_framework_api_key.permissions import BaseHasAPIKey, KeyParser
class BearerKeyParser(KeyParser):
keyword = "Bearer"
class HasAPIKey(BaseHasAPIKey):
model = APIKey # Or a custom model
key_parser = BearerKeyParser()
As rest_framework_api_key.models does not have a HasAPIKey class for example.
I assume it has to be something like this:
from rest_framework_api_key.models import APIKey
from rest_framework_api_key.permissions import BaseHasAPIKey, KeyParser
class BearerKeyParser(KeyParser):
keyword = "API-KEY"
class HasAPIKey(BaseHasAPIKey):
model = APIKey # Or a custom model
key_parser = BearerKeyParser()
But if I add the imports to settings.py, I get the error "django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.".
I guess I need a bit more handholding ;)
Metadata
Metadata
Assignees
Labels
docsRequest for documentationRequest for documentation