A Django REST framework package for OAuth2.0 and social account management
Project description
dj-oauth
dj-oauth is a Django REST framework package that provides OAuth2.0 and social account management. It supports various user types and offers flexible authentication methods, including username, email, phone number with OTP, Google, Apple, Facebook, and LinkedIn.
Features
- User Management: Handle different user types (users, admins, advocates, support) defined in Django settings.
- Authentication: Support for multiple authentication methods.
- Endpoints: Login, logout, refresh token, forgot password, profile management, and device management.
- Database: Use MySQL/PostgreSQL for user data and Redis for session management.
- User Information: Save required user information such as first name, last name, email, mobile number, age, and date of birth.
Installation
-
Clone the repository:
git clone https://github.com/yourusername/dj-oauth.git cd dj-oauth
-
Install the package:
pip install .
-
Add
dj_oauthtoINSTALLED_APPSin your Django settings:INSTALLED_APPS = [ ... 'dj_oauth', ]
-
Configure OAuth and social account settings in your Django settings:
AUTHENTICATION_BACKENDS = ( 'dj_oauth.authentication.google.GoogleBackend', 'dj_oauth.authentication.apple.AppleBackend', 'dj_oauth.authentication.facebook.FacebookBackend', 'dj_oauth.authentication.linkedin.LinkedInBackend', 'django.contrib.auth.backends.ModelBackend', ) DJ_OAUTH = { 'USER_ROLES': ['user', 'admin', 'advocate', 'support'], 'SOCIAL_AUTH': { 'google': { 'CLIENT_ID': 'your_google_client_id', 'CLIENT_SECRET': 'your_google_client_secret', }, 'apple': { 'CLIENT_ID': 'your_apple_client_id', 'CLIENT_SECRET': 'your_apple_client_secret', }, 'facebook': { 'CLIENT_ID': 'your_facebook_client_id', 'CLIENT_SECRET': 'your_facebook_client_secret', }, 'linkedin': { 'CLIENT_ID': 'your_linkedin_client_id', 'CLIENT_SECRET': 'your_linkedin_client_secret', } }, 'DEFAULT_AUTH_METHODS': ['username', 'email', 'phone_number', 'google', 'apple', 'facebook', 'linkedin'], } DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'your_db_name', 'USER': 'your_db_user', 'PASSWORD': 'your_db_password', 'HOST': 'localhost', 'PORT': '5432', } }
Usage
-
Run migrations to create the necessary database tables:
python manage.py migrate
-
Create a superuser to access the admin interface:
python manage.py createsuperuser
-
Start the Django development server:
python manage.py runserver
-
Access the API endpoints:
- Register:
POST /register/ - Login:
POST /login/ - Logout:
POST /logout/ - Refresh Token:
POST /token/refresh/ - Forgot Password:
POST /password/forgot/ - Profile:
GET/PUT /profile/ - Device Management:
POST/DELETE /device/manage/
- Register:
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
Feel free to customize this README.md file to better fit your project's specific needs. If you need any further assistance, just let me know! 🚀
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file ideal-dj-oauth2-0.1.0.tar.gz.
File metadata
- Download URL: ideal-dj-oauth2-0.1.0.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6649f799c63b86300c80dc366121381ceab93f1d6d7cf8f5534e9a6a508aec4b
|
|
| MD5 |
53bb2c96a42d0cb1cb2aa8468b31d5f5
|
|
| BLAKE2b-256 |
964a9353ef685b8d9a1f43a4ddbdac44826dc5999b9c077df82cff089f27b758
|