Custom requests auth class for Tastypie API key authentication

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
from requests.auth import AuthBase

class TastypieApiKeyAuth(AuthBase):
    """
    Sets the appropriate authentication headers
    for the Tastypie API key authentication.
    """
    def __init__(self, username, api_key):
        self.username = username
        self.api_key = api_key

    def __call__(self, r):
        r.headers['Authorization'] = 'ApiKey %s:%s' % (self.username, self.api_key)
        return r

More like this

  1. Debug middleware for displaying sql queries and template loading info when ?debug=true by SEJeff 2 years, 1 month ago
  2. Tastypie v0.9.11 LoginRequiredAuthorization by cotton 9 months, 1 week ago
  3. packjs templatetag by kyprizel 5 years, 5 months ago
  4. enani by andisthermal 2 years, 4 months ago
  5. Using descriptors for lazy attribute caching by djypsy 5 years, 9 months ago

Comments

(Forgotten your password?)