View Source UnkeyElixirSdk (UnkeyElixirSdk v0.1.0)
Documentation for UnkeyElixirSdk
.
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor.
Creates an API key for your users
Delete an api key for your users
Start the GenServer Returns {:ok, pid}
Verify a key from your users. You only need to send the api key from your user.
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
Creates an API key for your users
Returns a map with the key
%{"keyId" => "key_cm9vdCBvZiBnb29kXa", "key" => "xyz_AS5HDkXXPot2MMoPHD8jnL"}
examples
Examples
iex> UnkeyElixirSdk.create_key(%{"apiId" => "myapiid"})
%{"keyId" => "key_cm9vdCBvZiBnb29kXa", "key" => "xyz_AS5HDkXXPot2MMoPHD8jnL"}
iex> UnkeyElixirSdk.create_key(%{ "apiId" => "myapiid", "prefix" => "xyz", "byteLength" => 16, "ownerId" => "glamboyosa", "meta" => %{ "hello" => "world" }, "expires" => 1_686_941_966_471, "ratelimit" => %{ "type" => "fast", "limit" => 10, "refillRate" => 1, "refillInterval" => 1000 } })
%{"keyId" => "key_cm9vdCBvZiBnb29kXa", "key" => "xyz_AS5HDkXXPot2MMoPHD8jnL"}
@spec revoke_key(binary()) :: :ok
Delete an api key for your users
Returns :ok
examples
Examples
iex> UnkeyElixirSdk.revoke_key("key_cm9vdCBvZiBnb29kXa")
:ok
Start the GenServer Returns {:ok, pid}
examples
Examples
iex> UnkeyElixirSdk.start_link(%{token: "yourtoken"})
`{:ok, pid}`
iex> UnkeyElixirSdk.start_link(%{token: "yourtoken", base_url: "theunkeybaseurl"})
{:ok, pid}
Verify a key from your users. You only need to send the api key from your user.
Returns a map with whether the key is valid or not. Optionally sends ownerId
and meta
examples
Examples
iex> UnkeyElixirSdk.verify_key("xyz_AS5HDkXXPot2MMoPHD8jnL")
`%{"valid" => true,
"ownerId" => "chronark",
"meta" => %{
"hello" => "world"
}}`