we-promise/sure · error · StandardError

SnapTrade is not authorized

Error message

SnapTrade is not authorized

What it means

Error "SnapTrade is not authorized" thrown in we-promise/sure.

Source

Thrown at app/models/snaptrade_item/provided.rb:29

    Provider::Snaptrade.new(self)
  end

  # Exchange an authorization code for tokens and mark the item usable.
  def complete_oauth_exchange!(code:, redirect_uri:, code_verifier:)
    payload = Provider::Snaptrade.exchange_code(
      code: code,
      redirect_uri: redirect_uri,
      code_verifier: code_verifier
    )
    apply_oauth_tokens!(payload)
    update!(status: :good)
    payload
  end

  # Get the connection portal URL for linking brokerages
  def connection_portal_url(redirect_url:, broker: nil)
    provider = snaptrade_provider
    raise StandardError, "SnapTrade is not authorized" unless provider

    provider.get_connection_url(redirect_url: redirect_url, broker: broker)
  end

  # Fetch all brokerage connections from SnapTrade API. Returns Array<Hash>.
  def fetch_connections
    provider = snaptrade_provider
    return [] unless provider

    provider.list_connections
  rescue Provider::Snaptrade::ApiError => e
    Rails.logger.error "SnaptradeItem #{id} - Failed to list connections: #{e.message}"
    raise
  end

  private

    # Best-effort token revocation when the item is destroyed.

View on GitHub (pinned to e69894adb9)

When it happens

Trigger: Thrown at app/models/snaptrade_item/provided.rb:29 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of we-promise/sure@e69894adb9 (2026-08-21). Data as JSON: /api/errors/06f99f21ed605851. Report an issue: GitHub.