View Source Mobilizon.Service.Auth.Applications (Mobilizon v5.0.0-beta.1)

Module to handle applications management

Summary

Types

Link to this type

access_token_details()

View Source
@type access_token_details() :: %{
  access_token: String.t(),
  expires_in: pos_integer(),
  refresh_token: String.t(),
  refresh_token_expires_in: pos_integer(),
  scope: nil,
  token_type: String.t()
}

Functions

Link to this function

activate_device(user_code, user)

View Source
@spec activate_device(String.t(), Mobilizon.Users.User.t()) ::
  {:ok, Mobilizon.Applications.ApplicationDeviceActivation.t()}
  | {:error, Ecto.Changeset.t()}
  | {:error, :not_found}
  | {:error, :expired}
Link to this function

autorize(client_id, redirect_uri, scope, user_id)

View Source
@spec autorize(String.t(), String.t(), String.t(), integer()) ::
  {:ok, Mobilizon.Applications.ApplicationToken.t()}
  | {:error, :application_not_found}
  | {:error, :redirect_uri_not_in_allowed}
  | {:error, Ecto.Changeset.t()}
Link to this function

autorize_device_application(client_id, user_code)

View Source
@spec autorize_device_application(String.t(), String.t()) ::
  {:ok, Mobilizon.Applications.ApplicationDeviceActivation.t()}
  | {:error, Ecto.Changeset.t()}
  | {:error, :expired}
  | {:error, :access_denied}
  | {:error, :not_found}
Link to this function

create(name, redirect_uris, scope, website \\ nil)

View Source
@spec create(String.t(), [String.t()], String.t(), String.t() | nil) ::
  {:ok, Mobilizon.Applications.Application.t()}
  | {:error, Ecto.Changeset.t()}
  | {:error, :invalid_scope}
Link to this function

generate_access_token(client_id, client_secret, code, redirect_uri, scope)

View Source
@spec generate_access_token(
  String.t(),
  String.t(),
  String.t(),
  String.t(),
  String.t()
) ::
  {:ok, access_token_details()}
  | {:error,
     :application_not_found
     | :redirect_uri_not_in_allowed
     | :provided_code_does_not_match
     | :invalid_client_secret
     | :invalid_or_expired
     | :scope_not_included
     | any()}
Link to this function

generate_access_token_for_device_flow(client_id, device_code)

View Source
Link to this function

prune_old_application_device_activations()

View Source
Link to this function

refresh_tokens(refresh_token, user_client_id, user_client_secret)

View Source
@spec refresh_tokens(String.t(), String.t(), String.t()) ::
  {:ok, access_token_details()}
  | {:error, :invalid_client_credentials}
  | {:error, :invalid_refresh_token}
  | {:error, any()}
Link to this function

register_device_code(client_id, scope)

View Source
@spec register_device_code(String.t(), String.t() | nil) ::
  {:ok, Mobilizon.Applications.ApplicationDeviceActivation.t()}
  | {:error, :application_not_found}
  | {:error, :scope_not_included}
  | {:error, Ecto.Changeset.t()}
Link to this function

revoke_application_token(app_token)

View Source
@spec revoke_token(String.t()) ::
  {:ok, map()} | {:error, any(), any(), any()} | {:error, :token_not_found}