Skip to main content

Django app for Google Ads API authentication and basic functionality

Project description

Django Google Ads Authentication

A Django app that provides Google Ads API authentication and basic functionality for managing campaigns.

Features

  • OAuth2 authentication with Google Ads API
  • Store and manage refresh tokens
  • Track campaign statuses
  • Basic campaign management functionality

Installation

Install the package using pip:

pip install django-googleadsauth

local installation

  1. clone the repo
  2. add a volume in your docker compose setup pointing to the package directory
    volumes:
      - ./app/src:/app/src
      - ./app/logs:/app/logs
      - ./app/logs/gunicorn:/var/log/gunicorn
      - ./app/local-cdn:/app/local-cdn
      - /home/tarik/django-googleadsauth:/app/django-googleadsauth
  1. in your pyproject.toml add a dependency
dependencies = [
    "django>=5.1.5",
    ...
    "django-googleadsauth @ file:///app/django-googleadsauth"
]
  1. make sure to freeze the dependencies in the requirements.txt file
uv pip compile pyproject.toml -o requirements.txt 

Configuration

  1. Add googleadsauth to your INSTALLED_APPS in settings.py:
INSTALLED_APPS = [
    ...
    'googleadsauth',
    ...
]
  1. configure your .env file
GOOGLE_ADS_CLIENT_SECRET_PATH=/app/google-secret.json
GOOGLE_ADS_REDIRECT_URI=http://localhost:8082/google/oauth/redirect
GOOGLE_ADS_DEVELOPER_TOKEN=xxxxxxxx
GOOGLE_ADS_CLIENT_ID=xxxxx
GOOGLE_ADS_CLIENT_SECRET=xxxx
GOOGLE_ADS_TOKEN_URI=https://oauth2.googleapis.com/token
GOOGLE_ADS_MANAGER_ACCOUNT_ID=xxxx
  1. Add the required Google Ads API settings to your settings.py:
GOOGLE_ADS = {
    'CLIENT_SECRET_PATH': os.getenv('GOOGLE_ADS_CLIENT_SECRET_PATH'),
    'REDIRECT_URI': os.getenv('GOOGLE_ADS_REDIRECT_URI'),
    'DEVELOPER_TOKEN': os.getenv('GOOGLE_ADS_DEVELOPER_TOKEN'),
    'CLIENT_ID': os.getenv('GOOGLE_ADS_CLIENT_ID'),
    'CLIENT_SECRET': os.getenv('GOOGLE_ADS_CLIENT_SECRET'),
    'MANAGER_ACCOUNT_ID': os.getenv('GOOGLE_ADS_MANAGER_ACCOUNT_ID'),  # Optional
}
  1. Include the app URLs in your project's urls.py:
from django.urls import path, include

urlpatterns = [
    ...
    path('googleads/', include('googleadsauth.urls')),
    ...
]
  1. Run migrations:
python manage.py migrate googleadsauth

Usage

Authentication

  1. Navigate to /googleads/auth/ to start the OAuth2 authentication flow
  2. After successful authentication, the app will store the refresh token

Development

To set up for development:

  1. Clone the repository
  2. Install development dependencies
  3. Run the test suite

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_googleadsauth-0.1.0.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_googleadsauth-0.1.0-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file django_googleadsauth-0.1.0.tar.gz.

File metadata

  • Download URL: django_googleadsauth-0.1.0.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.15

File hashes

Hashes for django_googleadsauth-0.1.0.tar.gz
Algorithm Hash digest
SHA256 78f93e3148d0b3149a86c89e592139c5ab95150b5790c73c9841154eab1332b9
MD5 d6664b49a2001170031e0ddd70aeb190
BLAKE2b-256 fc6ad5787e8520fa423c1b0bfac594243685cb42e74b2ea7e56a431dea7ec49d

See more details on using hashes here.

File details

Details for the file django_googleadsauth-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_googleadsauth-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d74697ae8bf3aaa4795cb001a2af75e340838d7ecc5be93795d7c4ad634cc1ae
MD5 b8f2fe3177ebe0b60e87918f37d4477d
BLAKE2b-256 3b5e48eaa3a65ae9496be68956ce5b307133f012a732a57616c8196ee5b7b1c1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page