Class: Anthropic::Credentials::StaticToken

Inherits:
Object
  • Object
show all
Defined in:
lib/anthropic/credentials/static_token.rb

Overview

An access token provider that always returns a fixed token with no expiry.

This is the simplest credential provider, suitable for static API keys or tokens that don’t expire. It implements the access token provider protocol by responding to call with an AccessToken.

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ StaticToken

Returns a new instance of StaticToken.

Parameters:

  • token (String)

    the fixed token to return on every call



12
13
14
# File 'lib/anthropic/credentials/static_token.rb', line 12

def initialize(token)
  @token = token
end

Instance Method Details

#call(force_refresh: false) ⇒ AccessToken

Returns an AccessToken with the fixed token and no expiry.

Parameters:

  • force_refresh (Boolean) (defaults to: false)

    ignored; static tokens have no cache to bypass

Returns:

  • (AccessToken)

    the access token with expires_at: nil



20
21
22
# File 'lib/anthropic/credentials/static_token.rb', line 20

def call(force_refresh: false) # rubocop:disable Lint/UnusedMethodArgument
  AccessToken.new(token: @token, expires_at: nil)
end