Overview
This ticket is to create a feature for enabling social login using Google with Django Allauth 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 Google social login to enhance user authentication and streamline the login process.
Steps to Implement Google Social Login
-
Install Django Allauth:
- Install Django Allauth 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.google',
...
]
SITE_ID = 1
AUTHENTICATION_BACKENDS = [
...
'allauth.account.auth_backends.AuthenticationBackend',
...
]
LOGIN_REDIRECT_URL = '/'
LOGOUT_REDIRECT_URL = '/'
-
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 Google Social Account:
- Go to the Google Developer Console and create a new project.
- Set up OAuth consent screen.
- Create OAuth 2.0 Client IDs and get the Client ID and Client Secret.
- Add these credentials to the
settings.py:
SOCIALACCOUNT_PROVIDERS = {
'google': {
'SCOPE': [
'profile',
'email',
],
'AUTH_PARAMS': {
'access_type': 'online',
},
'OAUTH_PKCE_ENABLED': True,
}
}
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = '<your-client-id>'
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = '<your-client-secret>'
-
Update Database:
- Run migrations to apply changes:
-
Test the Integration:
- Start the server and test the Google login by navigating to
/accounts/login/.
Expected Behavior
Users should be able to log in using their Google accounts. Upon successful authentication, users will be redirected to the homepage or a specified URL.
Additional Information
Ensure that the OAuth consent screen is properly configured in the Google Developer Console, and the Client ID and Secret are kept secure.
- Simulateur: Stock market simulation platform using Django.
- Feature: Enable Google social login using Django Allauth.
- Steps: Install Django Allauth, update settings and URLs, configure Google OAuth, update database, and test the integration.
Overview
This ticket is to create a feature for enabling social login using Google with Django Allauth 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 Google social login to enhance user authentication and streamline the login process.
Steps to Implement Google Social Login
Install Django Allauth:
requirements.txtfile or running the command:Update Settings:
settings.pyfile to include Allauth configurations:Configure URLs:
urls.pyfile to include Allauth URLs:Set Up Google Social Account:
settings.py:Update Database:
Test the Integration:
/accounts/login/.Expected Behavior
Users should be able to log in using their Google accounts. Upon successful authentication, users will be redirected to the homepage or a specified URL.
Additional Information
Ensure that the OAuth consent screen is properly configured in the Google Developer Console, and the Client ID and Secret are kept secure.