more work on social login

This commit is contained in:
Sam
2021-03-16 13:24:25 +00:00
parent 6dec6be283
commit b81f868cac
6 changed files with 85 additions and 7 deletions

View File

@@ -57,7 +57,9 @@ INSTALLED_APPS = [
'storages',
'mapwidgets',
'django_admin_listfilter_dropdown',
'oauth2_provider',
'social_django',
'rest_framework_social_oauth2',
# local apps
'core',
@@ -130,13 +132,14 @@ AUTH_PASSWORD_VALIDATORS = [
AUTH_USER_MODEL = 'core.CustomUser'
AUTHENTICATION_BACKENDS = (
'social_core.backends.github.GithubOAuth2',
'social_core.backends.twitter.TwitterOAuth',
'social_core.backends.facebook.FacebookOAuth2',
'rest_framework_social_oauth2.backends.DjangoOAuth2',
'django.contrib.auth.backends.ModelBackend',
)
DRFSO2_PROPRIETARY_BACKEND_NAME = os.getenv('DRFSO2_PROPRIETARY_BACKEND_NAME') # E.g. Facebook
DRFSO2_URL_NAMESPACE = os.getenv('DRFSO2_URL_NAMESPACE') # namespace for reversing URLs
# DRF Options
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': [
@@ -144,6 +147,9 @@ REST_FRAMEWORK = {
],
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework_simplejwt.authentication.JWTAuthentication',
'oauth2_provider.contrib.rest_framework.OAuth2Authentication',
'rest_framework_social_oauth2.authentication.SocialAuthentication',
],
'DEFAULT_FILTER_BACKENDS': ['django_filters.rest_framework.DjangoFilterBackend'],
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',

View File

@@ -31,7 +31,7 @@ admin.site.site_header = 'LaTiendaCOOP Administration'
urlpatterns = [
path('admin/', admin.site.urls),
path('activate/<uidb64>/<token>/',core_views.activate_user, name='activate_user'),
path('api/v1/oauth/', include('social_django.urls', namespace='social')),
path('api/v1/social-auth/', include('rest_framework_social_oauth2.urls')),
path('api/v1/token/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
path('api/v1/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
path('api/v1/token/verify/', TokenVerifyView.as_view(), name='token_verify'),