4 ms·
Not OP either, but I've been using Django REST framework with React.js, and I'm really enjoying it.
by Franciscouzo 8y ago
Not OP either, but I've been using Django REST framework with React.js, and I'm really enjoying it.
- knicholes 8y agoAny tips for how to use JWT authentication and get around CSRF tokens being in forms when combining DRF with a JS SPA UI?
- kennydude 8y agoThe way I've always done it is to not log the user in to a Django session. That way the SPA is the thing which holds the authentication, be it JWT or any other kind of token. If any other site tries to POST to the API on behalf of the current user they'll get a "Authentication credentials required" message.
- theptip 8y agoIf you want JWT, you can use https://github.com/GetBlimp/django-rest-framework-jwt https://github.com/GetBlimp/django-rest-framework-jwt -- that provides another authentication class, and you can then auth with `Accept: Bearer <jwt>`. If you don't need JWT (I'd probably leave it out next time round) then Django Rest Framework comes with a simpler bearer token auth class (among others): http://www.django-rest-framework.org/api-guide/authentication/#tokenauthentication http://www.django-rest-framework.org/api-guide/authenticatio.... edit to add - if you're asking specifically about sharing sessions between the JS app and the Django server-side form, I believe this is what you're looking for:http://www.django-rest-framework.org/api-guide/authentication/#sessionauthentication http://www.django-rest-framework.org/api-guide/authenticatio..., i.e. you'll still need to pass the csrf token into the JS app.