1

So I am trying to get comfortable using api-keys and this is a package I found and it seems promising. I added the

from rest_framework_api_key.permissions import HasAPIKey
permission_classes = [HasAPIKey]

Also in settings changed the custom header with

API_KEY_CUSTOM_HEADER = "HTTP_API_KEY"

and looked at the documentation, but no matter what I pass in as an argument in my url it seems to not work. I pass in http://127.0.0.1:8000/api/questions/API-KEY:********/ with my prefix key and it doesn't work. Any help?

galfisher
  • 1,122
  • 1
  • 13
  • 24
somedude1234
  • 55
  • 2
  • 10

1 Answers1

2

The key is suppose to be passed via request header, NOT the url.

Here is the documentation: https://florimondmanca.github.io/djangorestframework-api-key/guide/#making-authorized-requests

Abid A
  • 7,588
  • 4
  • 32
  • 32
  • oh gotcha now, dumb question. How exactly would I do that? like where would I put the argument? – somedude1234 Jul 09 '19 at 14:26
  • 1
    To be clear, you wouldn't do this in a browser. The key is suppose to be passed as part of the header in your request. Something like this: `https://stackoverflow.com/a/13827087/152653` – Abid A Jul 09 '19 at 18:39