Skip to content
This repository has been archived by the owner on Dec 26, 2023. It is now read-only.

Commit

Permalink
fix: fix settings
Browse files Browse the repository at this point in the history
  • Loading branch information
mhd-medfa committed Aug 12, 2023
1 parent 364023b commit e61c76b
Showing 1 changed file with 10 additions and 54 deletions.
64 changes: 10 additions & 54 deletions backend/backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@


# Take environment variables from .env file

environ.Env.read_env(os.path.join(BASE_DIR, ".env"))

environ.Env.read_env(os.path.join(BASE_DIR, '.env.example'))

# SECURITY WARNING: don't run with debug turned on in production!
# False if not in os.environ because of casting above
DEBUG = env("DEBUG")
DEBUG = env('DEBUG')


# GDAL_LIBRARY_PATH = '/opt/homebrew/opt/gdal/lib/libgdal.dylib'
Expand All @@ -39,7 +37,7 @@
# exception if SECRET_KEY not in os.environ
# SECURITY WARNING: keep the secret key used in production secret!

SECRET_KEY = env("SECRET_KEY")
SECRET_KEY = env('SECRET_KEY')

ALLOWED_HOSTS = ["*",]
# trusted origin for aws app runner
Expand Down Expand Up @@ -68,9 +66,6 @@
"allauth.socialaccount.providers.google",

"drf_spectacular",
"oauth2_provider",
"social_django",
"drf_social_oauth2",
]

MIDDLEWARE = [
Expand All @@ -96,9 +91,7 @@
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",

"django.template.context_processors.request",

],
},
},
Expand All @@ -107,51 +100,14 @@

REST_FRAMEWORK = {
# YOUR SETTINGS
"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",
"DEFAULT_AUTHENTICATION_CLASSES": (
"oauth2_provider.contrib.rest_framework.OAuth2Authentication", # django-oauth-toolkit >= 1.0.0
"drf_social_oauth2.authentication.SocialAuthentication",
),
'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema',
}

AUTHENTICATION_BACKENDS = (
# Facebook OAuth2
"social_core.backends.facebook.FacebookAppOAuth2",
"social_core.backends.facebook.FacebookOAuth2",
# Google OAuth2
"social_core.backends.google.GoogleOAuth2",
# drf_social_oauth2
"drf_social_oauth2.backends.DjangoOAuth2",
# Django
"django.contrib.auth.backends.ModelBackend",
)

# Facebook configuration
SOCIAL_AUTH_FACEBOOK_KEY = os.environ["FACEBOOK_KEY"]
SOCIAL_AUTH_FACEBOOK_SECRET = os.environ["FACEBOOK_SECRET"]


# Define SOCIAL_AUTH_FACEBOOK_SCOPE to get extra permissions from Facebook.
# Email is not sent by default, to get it, you must request the email permission.
SOCIAL_AUTH_FACEBOOK_SCOPE = ["email"]
SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAMS = {"fields": "id, name, email"}

# Google configuration
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = os.environ["GOOGLE_KEY"]
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = os.environ["GOOGLE_SECRET"]

# Define SOCIAL_AUTH_GOOGLE_OAUTH2_SCOPE to get extra permissions from Google.
SOCIAL_AUTH_GOOGLE_OAUTH2_SCOPE = [
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/userinfo.profile",
]


SPECTACULAR_SETTINGS = {
"TITLE": "Ba7besh API",
"DESCRIPTION": "Ba7besh backend API - for Ba7besh App use only",
"VERSION": "1.0.0",
"SERVE_INCLUDE_SCHEMA": False,
'TITLE': 'Ba7besh API',
'DESCRIPTION': 'Ba7besh backend API - for Ba7besh App use only',
'VERSION': '1.0.0',
'SERVE_INCLUDE_SCHEMA': False,
# OTHER SETTINGS
}

Expand Down Expand Up @@ -222,7 +178,7 @@
'allauth.account.auth_backends.AuthenticationBackend',
]

SITE_ID = 1
SITE_ID = 2

SOCIALACCOUNT_PROVIDERS = {
'google': {
Expand All @@ -235,4 +191,4 @@
},
'OAUTH_PKCE_ENABLED': True,
}
}
}

0 comments on commit e61c76b

Please sign in to comment.