View Source ExPipedrive.Oauth.Token (ex_pipedrive v0.1.0)

OAuth token bundle from Pipedrive's token endpoint.

Preserves api_domain, expiry, and scope so host apps can refresh and rebuild clients without losing tenant metadata.

Summary

Functions

Returns true when the access token is expired or within skew_seconds of expiry.

Builds a token from a Pipedrive OAuth token JSON body.

Types

@type t() :: %ExPipedrive.Oauth.Token{
  access_token: String.t(),
  api_domain: String.t() | nil,
  expires_at: DateTime.t() | nil,
  expires_in: non_neg_integer() | nil,
  refresh_token: String.t(),
  scope: String.t() | nil,
  token_type: String.t() | nil
}

Functions

Link to this function

expired?(token, skew_seconds)

View Source
@spec expired?(t(), non_neg_integer()) :: boolean()

Returns true when the access token is expired or within skew_seconds of expiry.

Tokens without expires_at are treated as not expired (caller must refresh on 401).

Link to this function

from_response(map, opts \\ [])

View Source
@spec from_response(
  map(),
  keyword()
) :: t()

Builds a token from a Pipedrive OAuth token JSON body.

Computes expires_at from expires_in when present. Pass default_api_domain: when the response omits api_domain (e.g. some refresh responses) so the tenant domain is preserved.