Module: MCP::Client::OAuth::StorageBackedProvider
- Included in:
- ClientCredentialsProvider, Provider
- Defined in:
- lib/mcp/client/oauth/storage_backed_provider.rb
Overview
Shared token/credential persistence for the OAuth provider classes (‘Provider` for the authorization-code flow and `ClientCredentialsProvider` for the client_credentials flow). The two grants differ in how they authenticate, but both read and write the same two pieces of state through a `storage` object: the token response and the client information. This module supplies that delegation so the `Flow` orchestrator can treat any provider uniformly.
Including classes must set ‘@storage` to an object responding to `tokens`, `save_tokens(tokens)`, `client_information`, and `save_client_information(info)` (see `InMemoryStorage`).
Instance Method Summary collapse
- #access_token ⇒ Object
- #clear_tokens! ⇒ Object
- #client_information ⇒ Object
- #save_client_information(info) ⇒ Object
- #save_tokens(tokens) ⇒ Object
- #tokens ⇒ Object
Instance Method Details
#access_token ⇒ Object
17 18 19 |
# File 'lib/mcp/client/oauth/storage_backed_provider.rb', line 17 def access_token tokens&.dig("access_token") || tokens&.dig(:access_token) end |
#clear_tokens! ⇒ Object
37 38 39 |
# File 'lib/mcp/client/oauth/storage_backed_provider.rb', line 37 def clear_tokens! @storage.save_tokens(nil) end |
#client_information ⇒ Object
29 30 31 |
# File 'lib/mcp/client/oauth/storage_backed_provider.rb', line 29 def client_information @storage.client_information end |
#save_client_information(info) ⇒ Object
33 34 35 |
# File 'lib/mcp/client/oauth/storage_backed_provider.rb', line 33 def save_client_information(info) @storage.save_client_information(info) end |
#save_tokens(tokens) ⇒ Object
25 26 27 |
# File 'lib/mcp/client/oauth/storage_backed_provider.rb', line 25 def save_tokens(tokens) @storage.save_tokens(tokens) end |
#tokens ⇒ Object
21 22 23 |
# File 'lib/mcp/client/oauth/storage_backed_provider.rb', line 21 def tokens @storage.tokens end |