I'm not sure what use case you're trying to target, but the
``BasicAuthentication`` & ``DigestAuthentication`` classes already do
this (see https://github.com/toastdriven/django-tastypie/blob/master/tastypie/authentication.py#L42-66
& https://github.com/toastdriven/django-tastypie/blob/master/tastypie/authentication.py#L169-195).
I'd recommend a similar approach.
Daniel