struct

Crabbit::OAuth2Config

Inherits Struct < Value < Object

OAuth 2 client-credentials and refresh settings.

The token endpoint must use HTTPS unless allow_insecure_transport is explicitly enabled for isolated development. Stream endpoints must also use TLS when this configuration is attached to Configuration.

Constructors

new(token_endpoint : String | URI, client_id : String, client_secret : String, grant_type : String = "client_credentials", parameters : Hash(String, String) = {} of String => String, tls_context : OpenSSL::SSL::Context::Client | Nil = nil, connection_timeout : Time::Span = 30.seconds, request_timeout : Time::Span = 60.seconds, refresh_ratio : Float64 = 0.8, refresh_retry_delay : Time::Span = 1.second, refresh_retry_max_delay : Time::Span = 30.seconds, allow_insecure_transport : Bool = false)

Creates OAuth 2 settings.

parameters can carry provider-specific fields such as audience or scope; Crabbit always adds grant_type. The HTTP provider uses Basic client authentication and requires JSON containing access_token and a positive expires_in.

Token refresh is scheduled after refresh_ratio of the advertised lifetime. Retrieval and live re-authentication failures use exponential backoff between refresh_retry_delay and refresh_retry_max_delay.

Source

Instance methods

allow_insecure_transport

Returns whether unencrypted token and Stream transports are permitted.

Source
client_id

Returns the OAuth 2 client identifier.

Source
client_secret

Returns the OAuth 2 client secret.

Source
connection_timeout

Returns the token-endpoint connection timeout.

Source
grant_type

Returns the requested grant type.

Source
parameters

Returns additional form parameters included in token requests.

Source
refresh_ratio

Returns the fraction of token lifetime after which proactive refresh starts.

Source
refresh_retry_delay

Returns the first retry delay after refresh or re-authentication failure.

Source
refresh_retry_max_delay

Returns the maximum retry delay.

Source
request_timeout

Returns the token-endpoint read and write timeout.

Source
tls_context

Returns the optional trust/client-certificate context for the token endpoint.

Source
token_endpoint

Returns the parsed token endpoint URI.

Source