Class: Ask::MCP::Auth::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/ask/mcp/auth/token.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token, scheme: "Bearer") ⇒ Token

Returns a new instance of Token.



9
10
11
12
# File 'lib/ask/mcp/auth/token.rb', line 9

def initialize(token, scheme: "Bearer")
  @token = token
  @scheme = scheme
end

Instance Attribute Details

#schemeObject (readonly)

Returns the value of attribute scheme.



7
8
9
# File 'lib/ask/mcp/auth/token.rb', line 7

def scheme
  @scheme
end

#tokenObject (readonly)

Returns the value of attribute token.



7
8
9
# File 'lib/ask/mcp/auth/token.rb', line 7

def token
  @token
end

Instance Method Details

#apply(headers = {}) ⇒ Object



14
15
16
# File 'lib/ask/mcp/auth/token.rb', line 14

def apply(headers = {})
  headers.merge("Authorization" => "#{@scheme} #{@token}")
end

#to_sObject



18
19
20
# File 'lib/ask/mcp/auth/token.rb', line 18

def to_s
  "#{@scheme} #{@token[0..7]}..."
end