Register and login to django backend from iphone app and mobile browser

We are creating a Django backend with an iphone application, and also want to allow login through web browsers. The requirement is to be able to register and log in from a website / mobile browser, as well as through the iphone application. I also integrated django-registration for registration, login, logout, etc.

What would be the preferred approach so that registration, logging in, logging out can be done through the iphone application, as well as a mobile browser?

The most discussed approach is as follows:

  • Use tastypie for a RESTful API (or any other structure for REST) ​​(In this case, I assume it means creating an api to register and login)
  • For iphone, use RESTKIT to call and authenticate to perform registration, registration, etc.

Security and the ability to see only relevant data for the user are important in our case, since the data is very sensitive.

Any advice is greatly appreciated and will certainly help others too.

Thanks in advance. Neo

+4
source share
1 answer

If you have already integrated django registrations on your website, then you do not need to add tastypie only for logging in, logging out, etc.

Check out the documentation for registering django at https://django-registration.readthedocs.org/en/latest/quickstart.html#setting-up-urls . If you follow the steps for the default installation, which should provide you with URLs for logging in, logging out, etc. If the β€œRequired Templates” section doesn't make sense to you, read more about django at http://www.djangobook.com/en/2.0/chapter04.html

Once you have these URLs, you can simply use the AFNetworking library in iOS to create HTTP requests for login / logout, etc.

Typically, a django view for registration will execute GET and POST requests in different ways. If you make a GET request, it will format the registration form and display the HTML page. If you make a POST request, it will first extract the information required for registration from the request and create a new user. This will happen automatically for the Internet.

Using AFNetworking, you can create a view that displays the form locally and then makes the corresponding POST request after the user wants to register. The same procedure is used to enter the system.

+1
source

Source: https://habr.com/ru/post/1490638/


All Articles