Search code examples
pythondjangocsrfdjango-1.6

django csrf in mobile apps


I am developing a Android application, use django1.6 in server side, I want to POST some data to the server. But its shows error 403.

What I have to do to overcome the error(CSRF token missing or incorrect)?

Is it a good idea to remove csrf middleware (removing django.middleware.csrf.CsrfViewMiddleware from setting file)?

If not, what is an alternate solution=


Solution

  • This problem is not django specific. If you search CSRF Restful you will find many questions and answers about this. for e.g. this one

    At the basic level, I would say that CSRF is a mechanism to plug security issues affecting people who use browsers. As such, people who use mobile applications are not likely to be affected by this.

    You should keep the CSRF layer for people who access your application from web browsers and create a different scheme to access your api from other types of clients.