Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Notion Social Login Using Django Allauth #7

Open
antoinebou12 opened this issue Jul 3, 2024 · 0 comments
Open

Enable Notion Social Login Using Django Allauth #7

antoinebou12 opened this issue Jul 3, 2024 · 0 comments

Comments

@antoinebou12
Copy link
Member

antoinebou12 commented Jul 3, 2024

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

  1. 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
  2. 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 = '/'
  3. 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.
  4. Configure URLs:

    • Update the urls.py file to include Allauth URLs:
      from django.urls import path, include
      
      urlpatterns = [
          ...
          path('accounts/', include('allauth.urls')),
          ...
      ]
  5. 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>'
  6. Update Database:

    • Run migrations to apply changes:
      python manage.py migrate
  7. 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.


@antoinebou12 antoinebou12 changed the title Create the social signup using notion with django allauth Enable Notion Social Login Using Django Allauth Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant