https://github.com/mrf0rtuna4/django-discord-oauth2
🥢 Django application for secure user authorisation using Discord OAuth2
https://github.com/mrf0rtuna4/django-discord-oauth2
discord django oauth2 pypi
Last synced: 9 months ago
JSON representation
🥢 Django application for secure user authorisation using Discord OAuth2
- Host: GitHub
- URL: https://github.com/mrf0rtuna4/django-discord-oauth2
- Owner: mrf0rtuna4
- License: apache-2.0
- Archived: true
- Created: 2024-08-01T18:55:30.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-04-06T13:59:16.000Z (9 months ago)
- Last Synced: 2025-04-06T14:39:03.079Z (9 months ago)
- Topics: discord, django, oauth2, pypi
- Language: Python
- Homepage: https://pypi.org/project/django-discord-oauth2/
- Size: 39.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Django & Discord Oauth2
> âš **Warning:**
> This package is in the archive. Development will NOT be continued. Use with caution in production environments.
---
## Overview
`django-discord-oauth2` is a Django app that simplifies integrating Discord's OAuth2 authentication. It provides a ready-to-use OAuth2 flow to authenticate users with their Discord accounts.
### 🚨 Important Note on CSRF and Security
While handling OAuth tokens, be cautious about CSRF vulnerabilities. CSRF protection may sometimes block unsafe token handling methods, especially when passing tokens directly to the database. It is essential to follow best practices by using secure storage and transmission methods for tokens.
---
## Installation
Install the package via pip:
```bash
pip install django-discord-oauth2
```
---
## Usage
### Step 1: Add to Installed Apps
Add `django_discord_oauth2` to your Django `INSTALLED_APPS`:
```python
INSTALLED_APPS = [
'django_discord_oauth2',
# other apps
]
```
### Step 2: Configure URLs
Include the app’s URL configuration in your project’s `urls.py`:
```python
from django.urls import include, path
urlpatterns = [
path('oauth2/', include('django_discord_oauth2.urls')),
# other paths
]
```
### Step 3: Apply Migrations
Run the following command to create the necessary database models:
```bash
python manage.py migrate
```
### Step 4: Set Environment Variables
Add your Discord application's credentials in `settings.py`:
```python
DISCORD_CLIENT_ID = 'your_client_id'
DISCORD_CLIENT_SECRET = 'your_client_secret'
DISCORD_REDIRECT_URI = 'your_redirect_uri'
```
---
📜 How to Get Discord Credentials
1. Visit the [Discord Developer Portal](https://discord.com/developers/applications).
2. Create a new application or use an existing one.
3. Navigate to the **OAuth2** tab:

4. Copy your **Client ID**:

5. Click "Reset Secret" and copy the generated token:

6. Add a redirect URI matching your application:

---
### Step 5: Start the Server
Run the development server and initiate the login process at:
```
http://127.0.0.1:8000/oauth2/login/
```
---
## Contributing
Feel free to submit issues and pull requests. Contributions are welcome!
---
## License
This project is licensed under the Apache License 2.0. See the [LICENSE](LICENSE) file for more information.