ExOauth2Provider v0.2.3 ExOauth2Provider.OauthApplications View Source

The boundary for the OauthApplications system.

Link to this section Summary

Functions

Returns an %Ecto.Changeset{} for tracking application changes

Deletes an application

Gets a single application by uid

Gets a single application by uid and secret

Gets a single application by uid

Gets a single application for a resource owner

Returns all applications for a owner

Gets all authorized applications for a resource owner

Revokes all access tokens for an application and resource owner

Link to this section Functions

Link to this function change_application(application) View Source
change_application(%ExOauth2Provider.OauthApplications.OauthApplication{
  __meta__: term(),
  access_tokens: term(),
  id: term(),
  inserted_at: term(),
  name: term(),
  owner: term(),
  owner_id: term(),
  redirect_uri: term(),
  scopes: term(),
  secret: term(),
  uid: term(),
  updated_at: term()
}) :: Ecto.Changeset.t()

Returns an %Ecto.Changeset{} for tracking application changes.

Examples

iex> change_application(application)
%Ecto.Changeset{source: %OauthApplication{}}
Link to this function create_application(owner, attrs \\ %{}) View Source

Creates an application.

Examples

iex> create_application(user, %{name: "App", redirect_uri: "http://example.com"})
{:ok, %OauthApplication{}}

iex> create_application(user, %{name: ""})
{:error, %Ecto.Changeset{}}
Link to this function delete_application(application) View Source
delete_application(%ExOauth2Provider.OauthApplications.OauthApplication{
  __meta__: term(),
  access_tokens: term(),
  id: term(),
  inserted_at: term(),
  name: term(),
  owner: term(),
  owner_id: term(),
  redirect_uri: term(),
  scopes: term(),
  secret: term(),
  uid: term(),
  updated_at: term()
}) ::
  {:ok,
   %ExOauth2Provider.OauthApplications.OauthApplication{
     __meta__: term(),
     access_tokens: term(),
     id: term(),
     inserted_at: term(),
     name: term(),
     owner: term(),
     owner_id: term(),
     redirect_uri: term(),
     scopes: term(),
     secret: term(),
     uid: term(),
     updated_at: term()
   }}
  | {:error, Ecto.Changeset.t()}

Deletes an application.

Examples

iex> delete_application(application)
{:ok, %OauthApplication{}}

iex> delete_application(application)
{:error, %Ecto.Changeset{}}
Link to this function get_application(uid) View Source
get_application(String.t()) ::
  %ExOauth2Provider.OauthApplications.OauthApplication{
    __meta__: term(),
    access_tokens: term(),
    id: term(),
    inserted_at: term(),
    name: term(),
    owner: term(),
    owner_id: term(),
    redirect_uri: term(),
    scopes: term(),
    secret: term(),
    uid: term(),
    updated_at: term()
  }
  | nil

Gets a single application by uid.

Examples

iex> get_application("c341a5c7b331ef076eb4954668d54f590e0009e06b81b100191aa22c93044f3d")
%OauthApplication{}

iex> get_application("75d72f326a69444a9287ea264617058dbbfe754d7071b8eef8294cbf4e7e0fdc")
nil
Link to this function get_application(uid, secret) View Source
get_application(String.t(), String.t()) ::
  %ExOauth2Provider.OauthApplications.OauthApplication{
    __meta__: term(),
    access_tokens: term(),
    id: term(),
    inserted_at: term(),
    name: term(),
    owner: term(),
    owner_id: term(),
    redirect_uri: term(),
    scopes: term(),
    secret: term(),
    uid: term(),
    updated_at: term()
  }
  | nil

Gets a single application by uid and secret.

Examples

iex> get_application("c341a5c7b331ef076eb4954668d54f590e0009e06b81b100191aa22c93044f3d", "SECRET")
%OauthApplication{}

iex> get_application("75d72f326a69444a9287ea264617058dbbfe754d7071b8eef8294cbf4e7e0fdc", "SECRET")
nil
Link to this function get_application!(uid) View Source
get_application!(String.t()) ::
  %ExOauth2Provider.OauthApplications.OauthApplication{
    __meta__: term(),
    access_tokens: term(),
    id: term(),
    inserted_at: term(),
    name: term(),
    owner: term(),
    owner_id: term(),
    redirect_uri: term(),
    scopes: term(),
    secret: term(),
    uid: term(),
    updated_at: term()
  }
  | no_return()

Gets a single application by uid.

Raises Ecto.NoResultsError if the OauthApplication does not exist.

Examples

iex> get_application!("c341a5c7b331ef076eb4954668d54f590e0009e06b81b100191aa22c93044f3d")
%OauthApplication{}

iex> get_application!("75d72f326a69444a9287ea264617058dbbfe754d7071b8eef8294cbf4e7e0fdc")
** (Ecto.NoResultsError)
Link to this function get_application_for!(resource_owner, uid) View Source
get_application_for!(Ecto.Schema.t(), String.t()) ::
  %ExOauth2Provider.OauthApplications.OauthApplication{
    __meta__: term(),
    access_tokens: term(),
    id: term(),
    inserted_at: term(),
    name: term(),
    owner: term(),
    owner_id: term(),
    redirect_uri: term(),
    scopes: term(),
    secret: term(),
    uid: term(),
    updated_at: term()
  }
  | no_return()

Gets a single application for a resource owner.

Raises Ecto.NoResultsError if the OauthApplication does not exist for resource owner.

Examples

iex> get_application_for!(owner, "c341a5c7b331ef076eb4954668d54f590e0009e06b81b100191aa22c93044f3d")
%OauthApplication{}

iex> get_application_for!(owner, "75d72f326a69444a9287ea264617058dbbfe754d7071b8eef8294cbf4e7e0fdc")
** (Ecto.NoResultsError)
Link to this function get_applications_for(resource_owner) View Source
get_applications_for(Ecto.Schema.t()) :: [
  %ExOauth2Provider.OauthApplications.OauthApplication{
    __meta__: term(),
    access_tokens: term(),
    id: term(),
    inserted_at: term(),
    name: term(),
    owner: term(),
    owner_id: term(),
    redirect_uri: term(),
    scopes: term(),
    secret: term(),
    uid: term(),
    updated_at: term()
  }
]

Returns all applications for a owner.

Examples

iex> get_applications_for(resource_owner)
[%OauthApplication{}, ...]
Link to this function get_authorized_applications_for(resource_owner) View Source
get_authorized_applications_for(Ecto.Schema.t()) :: [
  %ExOauth2Provider.OauthApplications.OauthApplication{
    __meta__: term(),
    access_tokens: term(),
    id: term(),
    inserted_at: term(),
    name: term(),
    owner: term(),
    owner_id: term(),
    redirect_uri: term(),
    scopes: term(),
    secret: term(),
    uid: term(),
    updated_at: term()
  }
]

Gets all authorized applications for a resource owner.

Examples

iex> get_authorized_applications_for(owner)
[%OauthApplication{},...]
Link to this function put_scopes(changeset, server_scopes) View Source
Link to this function revoke_all_access_tokens_for(application, resource_owner) View Source
revoke_all_access_tokens_for(
  %ExOauth2Provider.OauthApplications.OauthApplication{
    __meta__: term(),
    access_tokens: term(),
    id: term(),
    inserted_at: term(),
    name: term(),
    owner: term(),
    owner_id: term(),
    redirect_uri: term(),
    scopes: term(),
    secret: term(),
    uid: term(),
    updated_at: term()
  },
  Ecto.Schema.t()
) :: [
  %ExOauth2Provider.OauthAccessTokens.OauthAccessToken{
    __meta__: term(),
    application: term(),
    application_id: term(),
    expires_in: term(),
    id: term(),
    inserted_at: term(),
    previous_refresh_token: term(),
    refresh_token: term(),
    resource_owner: term(),
    resource_owner_id: term(),
    revoked_at: term(),
    scopes: term(),
    token: term(),
    updated_at: term()
  }
]

Revokes all access tokens for an application and resource owner.

Examples

iex> revoke_all_access_tokens_for(application, resource_owner)
{:ok, [%OauthAccessToken{}]}
Link to this function update_application(application, attrs) View Source
update_application(
  %ExOauth2Provider.OauthApplications.OauthApplication{
    __meta__: term(),
    access_tokens: term(),
    id: term(),
    inserted_at: term(),
    name: term(),
    owner: term(),
    owner_id: term(),
    redirect_uri: term(),
    scopes: term(),
    secret: term(),
    uid: term(),
    updated_at: term()
  },
  Map.t()
) ::
  {:ok,
   %ExOauth2Provider.OauthApplications.OauthApplication{
     __meta__: term(),
     access_tokens: term(),
     id: term(),
     inserted_at: term(),
     name: term(),
     owner: term(),
     owner_id: term(),
     redirect_uri: term(),
     scopes: term(),
     secret: term(),
     uid: term(),
     updated_at: term()
   }}
  | {:error, Ecto.Changeset.t()}

Updates an application.

Examples

iex> update_application(application, %{name: "Updated App"})
{:ok, %OauthApplication{}}

iex> update_application(application, %{name: ""})
{:error, %Ecto.Changeset{}}
Link to this function validate_scopes(changeset) View Source
validate_scopes(Ecto.Changeset.t()) :: Ecto.Changeset.t()
Link to this function validate_scopes(changeset, server_scopes) View Source