View Source OAuth2TokenAgent.TokenRefreshStrategy (oauth2_token_agent v0.1.0)

Module defining a struct for representing strategies for refreshing tokens and the functions for applying them

Summary

Types

t()

Struct for the refresh timing strategy for OAuth2 tokens; multiple mechanisms

Functions

Returns true if at least one of the conditions is met and the token should be refreshed

Types

@type t() :: %OAuth2TokenAgent.TokenRefreshStrategy{
  every_seconds: integer() | nil,
  seconds_before_expires: integer() | nil
}

Struct for the refresh timing strategy for OAuth2 tokens; multiple mechanisms

Fields

  • :every_seconds - refresh the token if at least the specified number of seconds has elapsed since the last refresh
  • :seconds_before_expires - refresh the token if it will expire within the specified number of seconds

Functions

Link to this function

refresh_now?(strategy, lastRefreshed, expiresAt)

View Source
@spec refresh_now?(t(), Calendar.datetime(), Calendar.datetime()) :: boolean()

Returns true if at least one of the conditions is met and the token should be refreshed