View Source Squeeze.Fitbit.AuthBehaviour behaviour (OpenPace v0.0.1)

Behaviour module defining callbacks for Fitbit OAuth authentication.

Link to this section Summary

Callbacks

Generates the authorization URL for the OAuth2 flow.

Creates credential map from OAuth2 client response.

Gets an OAuth2 token, returns {:ok, client} or {:error, reason}.

Gets an OAuth2 token, raising an error if the request fails.

Creates a new OAuth2 client with default configuration.

Link to this section Types

@type auth_opts() :: [scope: scope(), expires_in: integer()]
@type client() :: OAuth2.Client.t()
@type code() :: String.t()
@type credential() :: %{
  access_token: binary(),
  refresh_token: binary(),
  provider: binary(),
  uid: binary()
}
@type grant_type() :: String.t()
@type headers() :: [{binary(), binary()}]
@type scope() :: String.t()
@type token() :: OAuth2.AccessToken.t()
@type token_opts() :: [
  code: code(),
  grant_type: grant_type(),
  refresh_token: binary()
]

Link to this section Callbacks

@callback authorize_url!() :: String.t()

Generates the authorization URL for the OAuth2 flow.

Link to this callback

authorize_url!(auth_opts)

View Source
@callback authorize_url!(auth_opts()) :: String.t()
@callback get_credential!(client()) :: credential()

Creates credential map from OAuth2 client response.

@callback get_token() :: {:ok, client()} | {:error, any()}

Gets an OAuth2 token, returns {:ok, client} or {:error, reason}.

@callback get_token(token_opts()) :: {:ok, client()} | {:error, any()}
Link to this callback

get_token(token_opts, headers)

View Source
@callback get_token(token_opts(), headers()) :: {:ok, client()} | {:error, any()}
@callback get_token!() :: client()

Gets an OAuth2 token, raising an error if the request fails.

@callback get_token!(token_opts()) :: client()
Link to this callback

get_token!(token_opts, headers)

View Source
@callback get_token!(token_opts(), headers()) :: client()
@callback new() :: client()

Creates a new OAuth2 client with default configuration.