Exemplo n.º 1
0
def has_valid_api_key(request):
    # The API key could be the query parameter 'api-key' or the
    # request header 'X-api-key'.

    api_key = (request.REQUEST.get('api-key', None) or
               request.REQUEST.get('api_key', None) or
               request.META.get('HTTP_X_API_KEY', None))
    return APIUser.is_valid(api_key)
Exemplo n.º 2
0
def has_valid_api_key(request):
    # The API key could be the query parameter 'api-key' or the
    # request header 'X-api-key'.
    api_key = (request.REQUEST.get('api-key', None)
               or request.REQUEST.get('api_key', None)
               or request.META.get('HTTP_X_API_KEY', None))
    if api_key:
        return APIUser.is_valid(api_key)

    return False