I want to get my head down into a small community website using Django Rest Framework as a backend and Next.JS as a frontend. I am struggling with the authentication module.
What is best practice? I thought about using Firebase as an auth provider but the implementation is quite hard - or at least I could not find good documentation.
I am now thinking of using the Djoser library to have django handle all authentication and user management.
My question is: What would you recommend to use? The official DRF website has a ton of third-party packages on this topic but I just can decide which one to use (https://www.django-rest-framework.org/api-guide/authentication/#third-party-packages)
CodePudding user response:
You can use Next Auth to handle JWT
authentication.
If you are using Token
authentication (rest_framework.authtoken), you can store the token in localStorage
and inject the token using axios.interceptors.request.use
for axios
, or create a custom fetch
method that injects said token in your fetch headers
.
CodePudding user response:
I did a little bit of research and I think I need to get my head around the basics. Thus I will follow this tutorial (https://www.youtube.com/watch?v=31R1gSvBn1g&list=PLPSM8rIid1a0SMqmFOfoHRbyfQ5ipQX79&index=1&ab_channel=LegionScript) to better understand the innerworkings between DRF and next js.
Thanks