Overview
Django backends are a strong fit for PulseGrid because they can keep the project secret key safely on the server.
Setup
Store:
- PULSEGRID_BASE_URL
- PULSEGRID_PUBLIC_KEY
- PULSEGRID_SECRET_KEY
- PULSEGRID_PROJECT_ID
in your Django environment or settings.
Code example
from pulsegrid import create_pulsegrid
pulsegrid = create_pulsegrid(
base_url="https://www.altrancconnect.com",
public_key="pk_your_public_key",
secret_key="sk_your_secret_key",
project_id="your_project_uuid",
)
token = pulsegrid.tokens.create(
identifier_id="user_123",
identifier_label="Kwandile",
allowed_channels=["demo-channel"],
)
pulsegrid.channel("demo-channel").publish(
"Hello from Django backend",
identifier_id="django_server",
identifier_label="Django Server",
)
Notes
This is one of the cleanest ways to integrate PulseGrid in a production backend.