README.md
# OTT
[](https://github.com/elielhaouzi/ott/actions) [](https://github.com/elielhaouzi/ott/issues) [](http://opensource.org/licenses/MIT) [](https://hex.pm/packages/ott) [](https://hex.pm/packages/ott)
A One-Time Token (OTT) is a unique and time-sensitive authentication mechanism used for secure login processes or transactions, ensuring each token is single-use only.
This package facilitates the creation and management of OTTs, empowering developers to seamlessly integrate this robust security measure into their applications.
## Installation
OTT is published on [Hex](https://hex.pm/packages/ott). The package can be installed by adding `ott` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:ott, "~> 0.1.0"}
]
end
```
After the packages are installed you must create a database migration to add the ott tables to your database:
```elixir
defmodule MyApp.Repo.Migrations.AddOTTTables do
use Ecto.Migration
def up do
OTT.Migrations.V1.up()
end
def down do
OTT.Migrations.V1.down()
end
end
```
Now, run the migration to create the table:
```sh
mix ecto.migrate
```
## Usage
```elixir
iex(1)> OTT.generate_token!(%{"user_id" => 1})
"xDkfMo23dm"
iex(2)> OTT.access_token_data("xDkfMo23dm")
%{"user_id" => 1}
iex(3)> OTT.access_token_data("xDkfMo23dm")
nil
```