Skip to content

[TW-4786] feat(admin): add callback URI CRUD and fix auth config#43

Merged
qasim-nylas merged 1 commit intomainfrom
feature/TW-4786-callback-uri-crud
Apr 4, 2026
Merged

[TW-4786] feat(admin): add callback URI CRUD and fix auth config#43
qasim-nylas merged 1 commit intomainfrom
feature/TW-4786-callback-uri-crud

Conversation

@qasim-nylas
Copy link
Copy Markdown
Collaborator

@qasim-nylas qasim-nylas commented Apr 4, 2026

Summary

  • Fixed nylas auth config callback URI creation — was using broken PATCH /v3/applications/{appID} endpoint, now uses dedicated POST /v3/applications/callback-uris
  • Added full CRUD commands at nylas admin callback-uris (aliases: callbacks, cb) for managing OAuth redirect endpoints
  • Added comprehensive unit tests (adapter + CLI) and integration tests with full CRUD lifecycle coverage

Problem

nylas auth config was failing to create callback URIs because it used PATCH /v3/applications/{appID} with a rebuilt callback_uris array. The Nylas v3 API has dedicated callback URI endpoints that are the correct way to manage these resources.

API Endpoints Verified

Operation Method Endpoint Status
List all GET /v3/applications/callback-uris 200 OK
Get one GET /v3/applications/callback-uris/:id 200 OK
Create POST /v3/applications/callback-uris 200 OK
Update PATCH /v3/applications/callback-uris/:id 200 OK
Delete DELETE /v3/applications/callback-uris/:id 200 OK

New CLI Commands

nylas admin callback-uris list                        # List all callback URIs
nylas admin callback-uris show <uri-id>               # Show one
nylas admin callback-uris create --url <url>          # Create (--platform web|ios|android)
nylas admin callback-uris update <uri-id> --url <url> # Update
nylas admin callback-uris delete <uri-id>             # Delete (with --yes to skip confirm)
nylas admin cb list --json                            # Short alias + JSON output

Changes

Fix: nylas auth config (internal/cli/auth/config.go)

  • Uses ListCallbackURIs to check if URI already exists
  • Uses CreateCallbackURI to add it via the dedicated endpoint
  • Removed dependency on selectedApp — works as long as config is loaded

Domain (internal/domain/)

  • admin.go — Added CreateCallbackURIRequest, UpdateCallbackURIRequest types
  • errors.go — Added ErrCallbackURINotFound sentinel error

Port (internal/ports/admin.go)

  • Added 5 methods to AdminClient interface: ListCallbackURIs, GetCallbackURI, CreateCallbackURI, UpdateCallbackURI, DeleteCallbackURI

Adapter (internal/adapters/nylas/)

  • admin.go — HTTP implementations for all 5 endpoints with proper validation
  • mock_admin.go — Mock stubs for testing
  • demo_admin.go — Demo mode stubs

CLI (internal/cli/admin/)

  • admin.go — Registered callback-uris subcommand
  • callback_uris.go — Full CRUD commands (list, show, create, update, delete)

Tests

  • admin_callback_uris_test.go (adapter) — 11 tests: happy paths, empty results, empty ID validation, server errors, not-found
  • callback_uris_test.go (CLI) — 6 tests: command structure, flags, aliases, defaults
  • admin_callback_uris_test.go (integration) — 5 tests: help, list, JSON, full CRUD lifecycle, alias
  • admin_test.go — Updated expected subcommands to include callback-uris

Docs

  • docs/COMMANDS.md — Added callback URIs to admin command reference
  • docs/commands/admin.md — Full section with usage examples, flags, and note about auth config auto-creation

Test plan

  • go build ./... passes
  • go vet ./... passes
  • Unit tests pass: go test ./internal/adapters/nylas/... ./internal/cli/admin/...
  • All 5 endpoints verified against live Nylas API (list, get, create, update, delete)
  • nylas admin callback-uris list — table output works
  • nylas admin callback-uris list --json — valid JSON output
  • nylas admin cb list — alias works
  • Integration tests: go test -tags integration ./internal/cli/integration/... -run CallbackURI

JIRA: TW-4786 (linked to Epic TW-4638 — Nylas CLI)

…nfig

Fix `nylas auth config` callback URI creation which was using the wrong
API endpoint (PATCH /v3/applications/{appID}), and add full CRUD
management commands at `nylas admin callback-uris`.

API endpoints verified and implemented:
- GET    /v3/applications/callback-uris        (list)
- GET    /v3/applications/callback-uris/:id    (get)
- POST   /v3/applications/callback-uris        (create)
- PATCH  /v3/applications/callback-uris/:id    (update)
- DELETE /v3/applications/callback-uris/:id    (delete)
@qasim-nylas qasim-nylas requested a review from AaronDDM April 4, 2026 16:27
Copy link
Copy Markdown
Collaborator

@AaronDDM AaronDDM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@qasim-nylas qasim-nylas merged commit b819789 into main Apr 4, 2026
6 checks passed
@qasim-nylas qasim-nylas deleted the feature/TW-4786-callback-uri-crud branch April 4, 2026 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants