How to intergarte react native front end with django backend - django

Post Method Used In ReactNative
Error raised
Forbidden: /api/login/
I created a user API using djangorest framework and it is functioning well, however i dont know how to add it to my react native front end for authentication. I would like users to login and the drf to authenticate them. Is there a tutorial i can follow, i tried to look at a few but they didnt work for me. I'm new to react native. Would appreciate elaborate answers and shared resources
Currently using expo cli and unable to fetch data from drf(django rest framework).
is there a way i can request my post method to use djangosessions for authentication instead of auth tokens
the method in the image only works if
'rest_framework.authentication.SessionAuthentication',
is disabled and this is used to get data in api so it cannot be excluded

welcome to ReactNative
You can use different libraries to handle an api request.
Take a look at axios:
https://github.com/axios/axios

Related

Auth Management with Django Rest Framework, Next.JS and?

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)
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.

Django REST authentication with React/ Redux

I am building a web app with a Django backend and React/Redux frontend running on separate servers. I have begun to try and start working on authentication and I cannot find a tutorial that suits my needs. Every tutorial either uses deprecated modules like drf-jwt (as opposed to simple-jwt) or has a simple mono-server that houses both the backend and the frontend in one directory. The former is useless and I do not want to do the latter as I like having the two separate servers for when I move on to deployment. Now can someone direct me to a good source of knowledge for getting this done? It doesn't have to be a tutorial it can be anything. I am really lost and I do not know how to begin.
you can use 3rd party packages djoser: Provides a set of views to handle basic actions such as registration, login, logout, password reset and account activation. for more information: https://pypi.org/project/djoser/
I'm using token authentication from Django Rest Framework so, after a login/password verification, the token on response can be used on any DRF endpoint.

Where should I make a python-twitter API call in my Django/React webapp

I'm creating a full stack web app using react, react-redux, and Django-rest, and I need to make an API call using the python-twitter api, then display the data from this request in my react frontend. The flow of control will be a user enters their twitter username in the frontend, which needs to trigger an API call using this username in the Django backend. Then the data from this call needs to be fed back into the React frontend using redux. Where should I be making this API call in the Django backend?
You can make authentication and configuration of the python-twitter in Django Backend. Then you can simply call the API's from the react web application. I have made for it. Here you go: python-twitter boiler-plate. Hope this helps :)

Issues with social login with vuejs and django-rest-auth

I am working with APIs for the first time and was looking at how to set up social app authentication for the project. I have django-rest-auth set up for the backend that basically uses the django allauth framework. So when I pass an access token to the backend using the API view, it works.
Now that I have moved to vuejs for the front end, I am absolutely clueless on how to make it work with my API.
Any help would be greatly appreciated. I'm a total beginner for vuejs and have been working on django framework for a bit more than a month. Thanks in advance!
My URL settings in VueJS:
The error I get is:
Cross origin content is blocked by same origin policy. Use https://github.com/ottoyiu/django-cors-headers to allow cross origin access. If you are interested in details https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS

Django Angular Facebook authentication

I want to do a very simple web app where you can log-in using your facebook account.
I am very comfortable with the django framework and also angularjs. I have an idea how to integrate these two using tastypie api framework for django.
So if I am correct django's backend would be throwing some JSON which can be used by angularjs and so on.
Where I am confused is the authentication mechanism with facebook.
How do I integrate the Facebook's authentication with my app ?
What would be a good design for such an app ?
I am not expecting a complete design or architecture for my app from anyone , but some direction so that I can go forward with the app .
Thanks :)
I wrote a small article on this subject as it seems it was not clearly explained anywhere. I found it easily done with django-rest-framework instead of tastypie though.
Here are the main steps used to authenticate (I’ll try to add a little schema to illustrate) :
On the angular side, user authenticate on facebook with Oauth.io API (it could be directly with Facebook js API).
Client gets a Facebook authentication token.
FB token is used to ask for authentication on server side.
python-social-auth authenticate with FB with the given token.
django-rest-framework sends back to client a auth token for REST API calls.
Angular client passes the token in headers when making API calls.
You can find my article here about facebook angularjs auth with a django rest backend
This repo is designed with php on authenticate server side but it has all of the facebook login code you would need for angular. It should give you an overall idea of how to get started:
https://github.com/Terumi/AngularJS-Facebook-Login