5

I am a nodejs developer but currently migrating to django(being a python lover). I am trying to implement OAuth2 in Django Rest Framework but I don't know how to start.

In nodejs, there is passportjs library which is well maintained, and it's got stratigies for every possible authentication type. What about django rest framework ? User name/password auth seems straightforward but oauth2 is not well covered.

In DRF docs here, It mentions two libraries for oauth. The first is django-oauth-toolkit which is well maintained but after going through docs, I didn't seem to understand much, it doesn't even talk about googl/facebook oauth. I am not sure what it is used for, anyway. The second one is django-rest-framework-social-oauth2 which seems to be straightforward but it's not been touched for over a year, it's probably not maintained any more.

So, How do you guys do oauth2 in your DRF projects ?

ahmed osama
  • 430
  • 1
  • 5
  • 16
  • have you checked [django-allauth](https://github.com/pennersr/django-allauth)? – henriquesalvaro Jul 26 '20 at 00:45
  • It doesn't integrate with django rest framework – ahmed osama Jul 26 '20 at 08:47
  • 1
    You can use `django-rest-framework-social-oauth2` module. There are examples for Facebook and Google integration on their Github: https://github.com/RealmTeam/django-rest-framework-social-oauth2 I also found these posts extremely helpful: https://www.toptal.com/django/integrate-oauth-2-into-django-drf-back-end https://medium.com/@katherinekimetto/simple-facebook-social-login-using-django-rest-framework-e2ac10266be1 I hope these links can help! – s.tafazzoli Aug 25 '20 at 08:45

1 Answers1

0

I hope you have solved this already. You can check my repo: It offers a simple way of authenticating against major ouath2 vendors. Here it is https://github.com/wagnerdelima/drf-social-oauth2.

You can also check my other repo https://github.com/wagnerdelima/facebook_setup. It integrates https://github.com/wagnerdelima/drf-social-oauth2 as an example to make it easy for newcomers.

wagnerdelima
  • 340
  • 1
  • 9
  • 18