Class: Basecamp::Oauth::Exchange
- Inherits:
-
Object
- Object
- Basecamp::Oauth::Exchange
- Defined in:
- lib/basecamp/oauth/exchange.rb
Overview
Handles OAuth 2 token exchange and refresh operations.
Instance Method Summary collapse
-
#exchange(request) ⇒ Token
Exchanges an authorization code for access and refresh tokens.
-
#initialize(http_client: nil, timeout: 30) ⇒ Exchange
constructor
A new instance of Exchange.
-
#refresh(request) ⇒ Token
Refreshes an access token using a refresh token.
Constructor Details
#initialize(http_client: nil, timeout: 30) ⇒ Exchange
Returns a new instance of Exchange.
13 14 15 |
# File 'lib/basecamp/oauth/exchange.rb', line 13 def initialize(http_client: nil, timeout: 30) @http_client = http_client || build_default_client(timeout) end |
Instance Method Details
#exchange(request) ⇒ Token
Exchanges an authorization code for access and refresh tokens.
Supports both standard OAuth 2 and Basecamp's Launchpad legacy format.
Use use_legacy_format: true for Launchpad compatibility.
44 45 46 47 48 49 |
# File 'lib/basecamp/oauth/exchange.rb', line 44 def exchange(request) validate_exchange_request!(request) params = build_exchange_params(request) do_token_request(request.token_endpoint, params) end |
#refresh(request) ⇒ Token
Refreshes an access token using a refresh token.
Supports both standard OAuth 2 and Basecamp's Launchpad legacy format.
Use use_legacy_format: true for Launchpad compatibility.
74 75 76 77 78 79 |
# File 'lib/basecamp/oauth/exchange.rb', line 74 def refresh(request) validate_refresh_request!(request) params = build_refresh_params(request) do_token_request(request.token_endpoint, params) end |