Skip to content

Add OAuth Device Code Flow Support for Headless Environments #546

@chodges15

Description

@chodges15

This may be covered by issue #4, but I wanted to raise it as a separate issue as it is a key workflow for my organization.

The current OAuth implementation requires localhost callbacks
(http://localhost:5173/oauth/callback), which doesn't work on headless servers or remote
development environments where opening a browser locally isn't possible.

Problem:

  • Users on headless machines cannot complete OAuth authentication
  • SSH port forwarding is a workaround but adds complexity
  • User Auth Tokens are the only current alternative but pose security concerns for some deployments

Proposed Solution:
Implement OAuth 2.0 Device Code Flow (RFC 8628) as an alternative authentication method. This would
allow users to:

  1. Run a command that generates a device code and verification URL
  2. Open the URL on any device with a browser
  3. Enter the device code to authorize the application
  4. Complete authentication without requiring localhost callbacks

Example Flow:
sentry-mcp auth --device-code
Output: Go to https://sentry.io/device and enter code: ABC-123
User enters code in browser, auth completes automatically

Use Cases:

  • Remote development servers
  • Docker containers
  • CI/CD environments
  • Any headless deployment where browser access isn't available locally

Additional Context:
This is a standard OAuth flow supported by many platforms (GitHub, Google, Microsoft) specifically
for headless/device scenarios. It maintains security while enabling headless authentication.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions