Class: Auth0::Client

Inherits:
Object
  • Object
show all
Includes:
Mixins
Defined in:
lib/auth0/auth_client.rb

Overview

Unified client that provides both Authentication and Management APIs.

Authentication methods (signup, authorization_url, validate_id_token, etc.) are mixed in directly via Auth0::Mixins.

Management methods are delegated to an internal Auth0::Management instance, which is lazily created and automatically refreshed when the token changes.

Direct Known Subclasses

Auth0Client

Constant Summary collapse

MANAGEMENT_ACCESSORS =

All management sub-client accessors from Auth0::Management. When Fern adds new resources, add them here and they’ll be delegated. In the meantime, method_missing provides a safety net.

%i[
  actions
  anomaly
  attack_protection
  branding
  client_grants
  clients
  connection_profiles
  connections
  custom_domains
  device_credentials
  email_templates
  emails
  event_streams
  flows
  forms
  groups
  guardian
  hooks
  jobs
  keys
  log_streams
  logs
  network_acls
  organizations
  prompts
  refresh_tokens
  resource_servers
  risk_assessments
  roles
  rules
  rules_configs
  self_service_profiles
  sessions
  stats
  supplemental_signals
  tenants
  tickets
  token_exchange_profiles
  user_attribute_profiles
  user_blocks
  user_grants
  users
  verifiable_credentials
].freeze

Constants included from Mixins::HTTPProxy

Mixins::HTTPProxy::BASE_DELAY, Mixins::HTTPProxy::DEFAULT_RETRIES, Mixins::HTTPProxy::MAX_ALLOWED_RETRIES, Mixins::HTTPProxy::MAX_REQUEST_RETRY_DELAY, Mixins::HTTPProxy::MAX_REQUEST_RETRY_JITTER, Mixins::HTTPProxy::MIN_REQUEST_RETRY_DELAY

Instance Attribute Summary

Attributes included from Mixins::HTTPProxy

#base_uri, #headers, #retry_count, #timeout

Instance Method Summary collapse

Methods included from Mixins::Initializer

#authorization_header, #authorization_header_basic, included, #initialize

Methods included from Mixins::HTTPProxy

#add_headers, #call, #encode_uri, #request, #request_with_retry, #retry_options, #safe_parse_json, #url

Methods included from Mixins::Headers

#client_headers, #telemetry, #telemetry_encoded

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name) ⇒ Object

Fallback for new management accessors not yet in the explicit list



70
71
72
73
74
75
76
# File 'lib/auth0/auth_client.rb', line 70

def method_missing(method_name, *, &)
  if management.respond_to?(method_name)
    management.public_send(method_name, *, &)
  else
    super
  end
end

Instance Method Details

#managementAuth0::Management

Returns the underlying Auth0::Management instance. Lazily created and automatically refreshed when the token changes.

Returns:



85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/auth0/auth_client.rb', line 85

def management
  current_token = get_token
  if @_management.nil? || @_management_token != current_token
    @_management_token = current_token
    opts = { token: current_token, base_url: "#{@base_uri}/api/v2" }
    opts[:timeout] = @management_timeout if @management_timeout
    opts[:max_retries] = @management_max_retries if @management_max_retries
    opts[:headers] = @management_additional_headers if @management_additional_headers
    @_management = Auth0::Management.new(**opts)
  end
  @_management
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


78
79
80
# File 'lib/auth0/auth_client.rb', line 78

def respond_to_missing?(method_name, include_private = false)
  management.respond_to?(method_name, include_private) || super
end