Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
New files: - oauth_service.py: Shared OAuth 2.0 service supporting Google and Meta providers with token exchange, refresh, and storage - database/migrations/058_oauth_tokens.sql: oauth_tokens table with company/provider/service unique constraint - blueprints/api/routes_oauth.py: OAuth API endpoints for connect, callback, status, and disconnect flows Supports: - Google OAuth (GBP Business Profile, Search Console) - Meta OAuth (Facebook Pages, Instagram) - CSRF state validation, token refresh, expiry tracking - Per-company token storage with active/inactive status Requires .env config: - GOOGLE_OAUTH_CLIENT_ID, GOOGLE_OAUTH_CLIENT_SECRET (Google APIs) - META_APP_ID, META_APP_SECRET (Facebook/Instagram) - OAUTH_REDIRECT_BASE_URL (default: https://nordabiznes.pl) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
30 lines
1.2 KiB
SQL
30 lines
1.2 KiB
SQL
-- OAuth Tokens for external API integrations
|
|
-- Supports: Google (GBP Business Profile, Search Console), Meta (Facebook, Instagram)
|
|
|
|
CREATE TABLE IF NOT EXISTS oauth_tokens (
|
|
id SERIAL PRIMARY KEY,
|
|
company_id INTEGER NOT NULL REFERENCES companies(id) ON DELETE CASCADE,
|
|
user_id INTEGER NOT NULL REFERENCES users(id),
|
|
provider VARCHAR(50) NOT NULL, -- 'google', 'meta'
|
|
service VARCHAR(50) NOT NULL, -- 'gbp', 'search_console', 'facebook', 'instagram'
|
|
access_token TEXT NOT NULL,
|
|
refresh_token TEXT,
|
|
token_type VARCHAR(50) DEFAULT 'Bearer',
|
|
expires_at TIMESTAMP,
|
|
scopes TEXT, -- space-separated scopes
|
|
account_id VARCHAR(255), -- external account/page ID
|
|
account_name VARCHAR(255), -- external account/page name
|
|
metadata JSONB, -- additional provider-specific data
|
|
is_active BOOLEAN DEFAULT TRUE,
|
|
created_at TIMESTAMP DEFAULT NOW(),
|
|
updated_at TIMESTAMP DEFAULT NOW(),
|
|
UNIQUE(company_id, provider, service)
|
|
);
|
|
|
|
CREATE INDEX idx_oauth_tokens_company ON oauth_tokens(company_id);
|
|
CREATE INDEX idx_oauth_tokens_provider ON oauth_tokens(provider, service);
|
|
|
|
-- Grant permissions
|
|
GRANT ALL ON TABLE oauth_tokens TO nordabiz_app;
|
|
GRANT USAGE, SELECT ON SEQUENCE oauth_tokens_id_seq TO nordabiz_app;
|