I need to send cross-domain request with ajax to an app build with django rest framework (DRF). I'm aware that I need the csrf token to allow the request but not sure how to implement it.
Where in the flow do I obtain the token?
i think this is not possible since the purpose of the csrf_token is to prevent cross site request forgeries. here is the link https://docs.djangoproject.com/en/dev/ref/contrib/csrf/
though if you have access to the django app, you can put csrf_exempt decorator so that it accepts POST request even without crsf_token.
You need to pass the CSRF token along with any POST requests.
You can learn how to get this in Javascript at https://docs.djangoproject.com/en/dev/ref/contrib/csrf/; there's a complete code sample there.
I need to send cross-domain request with ajax to an app build with django rest framework (DRF). I'm aware that I need the csrf token to allow the request but not sure how to implement it.
Where in the flow do I obtain the token?
i think this is not possible since the purpose of the csrf_token is to prevent cross site request forgeries. here is the link https://docs.djangoproject.com/en/dev/ref/contrib/csrf/
though if you have access to the django app, you can put csrf_exempt decorator so that it accepts POST request even without crsf_token.
You need to pass the CSRF token along with any POST requests.
You can learn how to get this in Javascript at https://docs.djangoproject.com/en/dev/ref/contrib/csrf/; there's a complete code sample there.
0 commentaires:
Enregistrer un commentaire