aliva
aliva

Reputation: 5720

throttling based on authentication class

in DRF docs there is a page about throttling api requests, I wanted to create a custom throttle class, to make something like twitter api (in twitter api direct user/passwords can make less requests/min compared to oauth requests)

my problem is how to find out which authentication class was used in current request?

Upvotes: 0

Views: 239

Answers (1)

pleasedontbelong
pleasedontbelong

Reputation: 20102

Reading the code I saw that DRF stores the authenticator instance on the request. So i guess you can do something like:

if type(request._authenticator).__name__ == "TokenAuthentication":

or something like that

Hope this helps

Upvotes: 1

Related Questions