Skip to content

nashcode2/midtermprojectAPI

Repository files navigation

API Project with OAuth

This project is an API built with Django that supports both regular authentication and OAuth login with Facebook and Google.

Installation

  1. Clone the repository
git clone https://github.com/nashcode2/midtermprojectAPI.git
  1. Go to the project folder
cd midtermprojectAPI
  1. Create a virtual environment
python -m venv venv
  1. Activate the environment
  • Windows:
    venv\Scripts\activate
  • Linux/Mac:
    source venv/bin/activate
  1. Install dependencies
pip install -r requirements.txt
  1. 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
    
  2. Run migrations:

python manage.py migrate
  1. Configure OAuth providers:
python setup_oauth.py

Run the Project Locally

  1. Start the development server:
python manage.py runserver
  1. Open in your browser:
    http://127.0.0.1:8000

Using with Ngrok (for OAuth Testing)

  1. Start your Django server:
python manage.py runserver
  1. In a new terminal, start ngrok:
ngrok http 8000
  1. Important: Always access the app via the HTTPS ngrok URL:
https://your-ngrok-subdomain.ngrok-free.dev
  1. Make sure your OAuth provider settings include your ngrok URLs:
    • See FACEBOOK_SETUP.md and NGROK_OAUTH_SETUP.md for details

Facebook OAuth Configuration

To use Facebook login:

  1. Create a Facebook App at developers.facebook.com
  2. Add Facebook Login product to your app
  3. Configure Valid OAuth Redirect URIs in Facebook Login settings:
    https://your-domain.com/accounts/facebook/login/callback/
    
  4. Set App Domains to include your domain
  5. Add your App ID and Secret to your .env file

For detailed instructions, see FACEBOOK_SETUP.md.

Author

  • nashcode2

Save the file.

Then push it to GitHub:

git add README.md git commit -m "Add README" git push -u origin main

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •