This project is an API built with Django that supports both regular authentication and OAuth login with Facebook and Google.
- Clone the repository
git clone https://github.com/nashcode2/midtermprojectAPI.git
- Go to the project folder
cd midtermprojectAPI
- Create a virtual environment
python -m venv venv
- Activate the environment
- Windows:
venv\Scripts\activate
- Linux/Mac:
source venv/bin/activate
- Install dependencies
pip install -r requirements.txt
-
Configure environment variables: Create a
.env
file in the project root with:# Facebook OAuth Settings FACEBOOK_APP_ID=your_facebook_app_id FACEBOOK_APP_SECRET=your_facebook_app_secret # Google OAuth Settings (optional) GOOGLE_CLIENT_ID=your_google_client_id GOOGLE_CLIENT_SECRET=your_google_client_secret # Django Settings DJANGO_SECRET_KEY=your_secret_key_here
-
Run migrations:
python manage.py migrate
- Configure OAuth providers:
python setup_oauth.py
- Start the development server:
python manage.py runserver
- Open in your browser:
http://127.0.0.1:8000
- Start your Django server:
python manage.py runserver
- In a new terminal, start ngrok:
ngrok http 8000
- Important: Always access the app via the HTTPS ngrok URL:
https://your-ngrok-subdomain.ngrok-free.dev
- Make sure your OAuth provider settings include your ngrok URLs:
- See
FACEBOOK_SETUP.md
andNGROK_OAUTH_SETUP.md
for details
- See
To use Facebook login:
- Create a Facebook App at developers.facebook.com
- Add Facebook Login product to your app
- Configure Valid OAuth Redirect URIs in Facebook Login settings:
https://your-domain.com/accounts/facebook/login/callback/
- Set App Domains to include your domain
- Add your App ID and Secret to your
.env
file
For detailed instructions, see FACEBOOK_SETUP.md
.
- nashcode2
Save the file.
Then push it to GitHub:
git add README.md git commit -m "Add README" git push -u origin main