1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.OAuth.App do
9 @type t :: %__MODULE__{}
12 field(:client_name, :string)
13 field(:redirect_uris, :string)
14 field(:scopes, {:array, :string}, default: [])
15 field(:website, :string)
16 field(:client_id, :string)
17 field(:client_secret, :string)
22 def register_changeset(struct, params \\ %{}) do
25 |> cast(params, [:client_name, :redirect_uris, :scopes, :website])
26 |> validate_required([:client_name, :redirect_uris, :scopes])
28 if changeset.valid? do
32 :crypto.strong_rand_bytes(32) |> Base.url_encode64(padding: false)
36 :crypto.strong_rand_bytes(32) |> Base.url_encode64(padding: false)