Class: Basecamp::Services::AuthorizationService

Inherits:
BaseService
  • Object
show all
Defined in:
lib/basecamp/services/authorization_service.rb

Overview

Service for authorization operations. This is the only service that doesn't require an account context.

Examples:

Get authorization info

auth = client.authorization.get
puts "Identity: #{auth["identity"]["email_address"]}"
auth["accounts"].each do ||
  puts "Account: #{["name"]} (#{["id"]})"
end

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from Basecamp::Services::BaseService

Instance Method Details

#getHash

Gets authorization information for the current user.

Delegates to Http#get_authorization_document, which resolves the issuer via resource-first OAuth discovery (SPEC.md §16) on the client's own configured base URL and fetches the fixed authorization.json path. Only the two soft fallback outcomes (+resource_discovery_failed+, no_as_advertised) fall back to Launchpad; every hard selection failure propagates as a Oauth::DiscoverySelectionError — a hard failure is never silently converted into a Launchpad request. This service passes NO issuer, config, or origin to the credentialed fetch, so there is no caller-supplied path through which the bearer token could be sent to a foreign host.

Returns the authenticated user's identity and list of accounts they have access to.

Returns:

  • (Hash)

    authorization info with string keys "identity" and "accounts" (parsed JSON, not symbol keys)

Raises:

See Also:



35
36
37
38
39
40
41
42
# File 'lib/basecamp/services/authorization_service.rb', line 35

def get
  # Wrap in with_operation like every other service call so observability
  # hooks (logging, metrics, tracing) see this credentialed request and its
  # failures too.
  with_operation(service: "authorization", operation: "get", is_mutation: false) do
    http.get_authorization_document.json
  end
end