Skip to content

feat: Add support for personal access token authentication via environment variables - #544

Merged
razor-x merged 1 commit into
mainfrom
claude/env-var-support-parity-o7fen9
Aug 13, 2026
Merged

razor-x merged 1 commit into
mainfrom
claude/env-var-support-parity-o7fen9

Conversation

@razor-x

@razor-x razor-x commented Aug 13, 2026

Copy link
Copy Markdown
Member

Summary

This PR adds support for authenticating with Seam using Personal Access Tokens via environment variables, and introduces a new WithoutWorkspace client for workspace-agnostic operations. It also adds validation to prevent mixing authentication methods.

Key Changes

  • Environment variable support: Added SEAM_PERSONAL_ACCESS_TOKEN and SEAM_WORKSPACE_ID environment variables that can be used to configure authentication without passing options to the constructor
  • Authentication method validation: Added logic to detect and reject conflicting authentication methods (both SEAM_API_KEY and SEAM_PERSONAL_ACCESS_TOKEN set simultaneously)
  • Option precedence: Constructor options take precedence over environment variables for both personal_access_token and workspace_id
  • WithoutWorkspace client improvements: Made personal_access_token parameter optional in WithoutWorkspace.initialize() to support environment variable configuration, with proper validation when neither option nor environment variable is provided
  • New parse method: Added parse_without_workspace_options() to handle option parsing for workspace-agnostic clients
  • Helper methods: Extracted get_api_key_from_env() and get_personal_access_token_from_env() to encapsulate environment variable logic and precedence rules
  • Documentation: Updated README with examples of using environment variables for both Seam.new() and Seam::Http::WithoutWorkspace.new()
  • Test coverage: Added comprehensive tests for environment variable support, option precedence, and error cases

Implementation Details

  • The get_api_key_from_env() method only consults the environment when no personal_access_token is provided, ensuring API key takes precedence
  • The get_personal_access_token_from_env() method only consults the environment when no api_key is set, maintaining proper authentication method precedence
  • Validation in get_api_key_from_env() raises SeamInvalidOptionsError if both SEAM_API_KEY and SEAM_PERSONAL_ACCESS_TOKEN environment variables are defined
  • The WithoutWorkspace client now properly validates that a personal access token is available (either via option or environment variable)

https://claude.ai/code/session_01Y6AAdyu2f6Z1PfDf3tnF3J

The JavaScript SDK resolves a personal access token and workspace id from
the environment, while this SDK only resolved SEAM_API_KEY. Match its
precedence rules: an option always wins over the environment, SEAM_API_KEY
is skipped when a personal access token is passed, SEAM_PERSONAL_ACCESS_TOKEN
is skipped when an api key is set, and defining both raises.

Seam::Http::WithoutWorkspace now takes an optional personal access token and
falls back to SEAM_PERSONAL_ACCESS_TOKEN.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y6AAdyu2f6Z1PfDf3tnF3J
@razor-x razor-x changed the title Add support for personal access token authentication via environment variables feat: Add support for personal access token authentication via environment variables Aug 13, 2026
@razor-x
razor-x marked this pull request as ready for review August 13, 2026 00:21
@razor-x
razor-x merged commit c98c046 into main Aug 13, 2026
17 checks passed
@razor-x
razor-x deleted the claude/env-var-support-parity-o7fen9 branch August 13, 2026 00:21
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