1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Mix.Tasks.Pleroma.App do
6 @moduledoc File.read!("docs/docs/administration/CLI_tasks/oauth_app.md")
11 @shortdoc "Creates trusted OAuth App"
13 def run(["create" | options]) do
17 OptionParser.parse!(options,
18 strict: [name: :string, redirect_uri: :string, scopes: :string],
19 aliases: [n: :name, r: :redirect_uri, s: :scopes]
24 String.split(opts[:scopes], ",")
26 ["read", "write", "follow", "push"]
30 client_name: opts[:name],
31 redirect_uris: opts[:redirect_uri],
36 with {:ok, app} <- Pleroma.Web.OAuth.App.create(params) do
37 shell_info("#{app.client_name} successfully created:")
38 shell_info("App client_id: " <> app.client_id)
39 shell_info("App client_secret: " <> app.client_secret)
41 {:error, changeset} ->
42 shell_error("Creating failed:")
44 Enum.each(Pleroma.Web.OAuth.App.errors(changeset), fn {key, error} ->
45 shell_error("#{key}: #{error}")