Packages

A small Elixir client for Kopo Kopo OAuth, M-PESA STK Push prompts, payment verification, and callback signature validation.

Current section

Files

Jump to
kopokopo lib mix tasks kopokopo.auth_check.ex
Raw

lib/mix/tasks/kopokopo.auth_check.ex

defmodule Mix.Tasks.Kopokopo.AuthCheck do
@moduledoc """
Checks whether the configured Kopo Kopo credentials can obtain an access token.
mix kopokopo.auth_check
"""
use Mix.Task
@shortdoc "Checks Kopo Kopo OAuth credentials"
@impl Mix.Task
def run(_args) do
Mix.Task.run("app.start")
case KopoKopo.auth_check() do
{:ok, token} ->
Mix.shell().info("Kopo Kopo auth OK.")
Mix.shell().info("Access token prefix: #{String.slice(token, 0, 8)}...")
{:error, reason} ->
Mix.raise("Kopo Kopo auth failed: #{inspect(reason)}")
end
end
end