This project was just to practice in the Django framework and challenge me in this framework.
allows you to see your profile and the servers you are in after your authentication in Discord, but according to Discord rules and the services it provides to us. So do not worry about stealing your identity and the servers you are on.
-
Clone this repo.
-
Open command prompt inside the folder where you cloned repo and enter this command
pip install -r requirements.txt
. -
Create Discord account and login with the browser.
-
Go to Discord Developer portal and create your own application, click OAuth2 and copy your client ID and client secret.
-
Then paste them into the .env file.
client_id = Your client id client_secret = Your client secret
-
In the same section of Oauth2, click on Add redirect and enter this address for callback.
http://127.0.0.1:8000/auth
If you want to run this project on a server or host, put your domain instead of 127.0.0.1:8000 and go to the settings.py file in the DiscordOauth2 folder and set DEBUG to False and put your domain in the ALLOWED_HOSTS list, e.g =>
www.mydomain.com
ormydomain.com
, then change redirect_uri tohttp://yourdomain/auth
And for static files, serving is the responsibility of the server or host(For more information). -
Then with the help of OAuth2 URL Generator In Oauth2, by selecting the url you added in Redirects in the SELECT REDIRECT URL section and checking
identify
andguilds
, the url generator will give you a url, copy it and paste it in .env fileauth_url_discord = The url you copied
-
Enter this command on command prompt
python manage.py runserver
-
If you encounter an error during Authentication, raise it here.
But some errors are related to the database, e.g => no such table django_section, so you can delete db.sqlite3 file and run this command on command prompt
python manage.py migrate
😁