Tastypie ApiKey Authentication not working for foreman/heroky

Thursday, July 10, 2014

I have an api that requires ApiKey authentication. If I am running this api using manage.py runserver locally it works just fine but if I am using foreman start both locally and deployed to heroku it gives the following error



{
"error_message": "'NoneType' object has no attribute 'DoesNotExist'",
"traceback": "Traceback (most recent call last):\n\n File \"/Users/carlosbalderas/.virtualenvs/recommenu/lib/python2.7/site-packages/tastypie/resources.py\", line 195, in wrapper\n response = callback(request, *args, **kwargs)\n\n File \"/Users/carlosbalderas/.virtualenvs/recommenu/lib/python2.7/site-packages/tastypie/resources.py\", line 435, in dispatch_detail\n return self.dispatch('detail', request, **kwargs)\n\n File \"/Users/carlosbalderas/.virtualenvs/recommenu/lib/python2.7/site-packages/tastypie/resources.py\", line 453, in dispatch\n self.is_authenticated(request)\n\n File \"/Users/carlosbalderas/.virtualenvs/recommenu/lib/python2.7/site-packages/tastypie/resources.py\", line 536, in is_authenticated\n auth_result = self._meta.authentication.is_authenticated(request)\n\n File \"/Users/carlosbalderas/.virtualenvs/recommenu/lib/python2.7/site-packages/tastypie/authentication.py\", line 197, in is_authenticated\n except (User.DoesNotExist, User.MultipleObjectsReturned):\n\nAttributeError: 'NoneType' object has no attribute 'DoesNotExist'\n"


I am using these curls to interact with my api (runserver)



curl -H "Authorization: ApiKey USERNAME:APIKEY" http://ift.tt/1xZqpxZ


(foreman)



curl -H "Authorization: ApiKey USERNAME:APIKEY" http://ift.tt/1mDxYpV


(heroku)



curl -H "Authorization: ApiKey USERNAME:APIKEY" http://ift.tt/1xZqpy3


Thanks in advance for your help!







http://ift.tt/1xZqrpw