What authentication should I use when using the Django Rest Framework and IOS application?

I have an iOS application that uses the Django REST-based API to store, update, retrieve data from a database. I need to provide two more of the following functions that store user data on the server:

  • Sign In Email
  • Sign in with Facebook

There seem to be two different authentication systems that I can use:

How do I handle this in my API?

+7
python django ios django-rest-framework
source share
1 answer

When you use the Django REST environment with iOS, if you are not using a browser, the standard Django authentication system is out of the question. This is detected through the DRF authentication system as SessionAuthentication and relies on your application to send cookies and a CSRF token with a request, which is usually not possible.

In most cases where you already use the Django authentication system, and you can trust your application password store, you would use something like BasicAuthentiction . Most people cannot, although they do not trust their application ecosystem, and therefore use a token-based authentication system like TokenAuthentication or OAuth2Authorization (in combination with the OAuth provider ). You can learn more about each type of authentication in this stack overflow answer .

But in your situation, you are mostly limited to using something like OAuth 2 . This is because you need to associate a user with a token, and most authentication systems require you to provide a username and password. For social accounts, this is usually not the case, and usually they cannot log in. OAuth 2 works in conjunction with the standard Django login, so you are not limited to just a username and password. I wrote more about how this works in this detailed stack overflow answer .

+13
source share

All Articles