Overview
This ticket is to create a feature for enabling social login using Notion on the Simulateur stock market simulation platform. The platform is built using Django and includes features for managing stock market scenarios, teams, user profiles, and an admin dashboard for controlling simulation parameters. The objective is to integrate Notion social login to enhance user authentication and streamline the login process.
Steps to Implement Notion Social Login
-
Install Django Allauth:
- Ensure Django Allauth is installed by adding it to your project's
requirements.txt file or running the command:
pip install django-allauth
-
Update Settings:
- Update the
settings.py file to include Allauth configurations:
INSTALLED_APPS = [
...
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.oauth2',
...
]
SITE_ID = 1
AUTHENTICATION_BACKENDS = [
...
'allauth.account.auth_backends.AuthenticationBackend',
...
]
LOGIN_REDIRECT_URL = '/'
LOGOUT_REDIRECT_URL = '/'
-
Create a Custom Notion Provider:
- Since Django Allauth does not come with a built-in Notion provider, create a custom provider by following the Django Allauth documentation on custom providers.
-
Configure URLs:
- Update the
urls.py file to include Allauth URLs:
from django.urls import path, include
urlpatterns = [
...
path('accounts/', include('allauth.urls')),
...
]
-
Set Up Notion Integration:
- Go to the Notion Developer Console and create a new integration.
- Get the Integration Token and add it to the
settings.py:
SOCIALACCOUNT_PROVIDERS = {
'notion': {
'SCOPE': [
'user.read',
'database.read',
],
'AUTH_PARAMS': {
'access_type': 'offline',
},
}
}
SOCIAL_AUTH_NOTION_KEY = '<your-client-id>'
SOCIAL_AUTH_NOTION_SECRET = '<your-client-secret>'
-
Update Database:
- Run migrations to apply changes:
-
Test the Integration:
- Start the server and test the Notion login by navigating to
/accounts/login/.
Expected Behavior
Users should be able to log in using their Notion accounts. Upon successful authentication, users will be redirected to the homepage or a specified URL.
Additional Information
Ensure that the Notion integration is properly configured in the Notion Developer Console, and the Client ID and Secret are kept secure.
Overview
This ticket is to create a feature for enabling social login using Notion on the Simulateur stock market simulation platform. The platform is built using Django and includes features for managing stock market scenarios, teams, user profiles, and an admin dashboard for controlling simulation parameters. The objective is to integrate Notion social login to enhance user authentication and streamline the login process.
Steps to Implement Notion Social Login
Install Django Allauth:
requirements.txtfile or running the command:Update Settings:
settings.pyfile to include Allauth configurations:Create a Custom Notion Provider:
Configure URLs:
urls.pyfile to include Allauth URLs:Set Up Notion Integration:
settings.py:Update Database:
Test the Integration:
/accounts/login/.Expected Behavior
Users should be able to log in using their Notion accounts. Upon successful authentication, users will be redirected to the homepage or a specified URL.
Additional Information
Ensure that the Notion integration is properly configured in the Notion Developer Console, and the Client ID and Secret are kept secure.