SkyFlyOne
Joken problem - (UndefinedFunctionError) function Joken.using/1 is undefined or private
Hello I’m facing some problems using Joken to set up JWT for my backend application. I found no solution. I’ve pasted the code below with the error. I think there is a conflict between the versions of Joker
defmodule ApiElixir.TokenManager do
use Joken
@secret "secret"
defp claims() do
%{
"iss" => "api_elixir",
"exp" => Timex.now() |> Timex.add(Timex.Duration.from_seconds(3600)) |> Timex.to_unix(),
"aud" => "user"
}
end
def encode() do
Joken.sign(%{}, @secret, claims())
end
def decode(token) do
case Joken.verify(token, @secret) do
{:ok, _claims} -> {:ok, "Token valide"}
{:error, reason} -> {:error, reason}
end
end
end
Error :
== Compilation error in file lib/token_manager.ex ==
** (UndefinedFunctionError) function Joken.__using__/1 is undefined or private
(joken 2.6.0) Joken.__using__([])
lib/token_manager.ex:2: (module)
Thanks all for the help
Most Liked
victorolinasc
@SkyFlyOne you should use Joken.Config and not Joken.
The docs also show you better intended ways of using Joken’s API. For instance, when “using” the config, you get some generated implementations of encode/decode and some others.
1
Hermanverschooten
Have you tried putting the statements inside a function inside your module?
1
Popular in Questions
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
Hello!
Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
Hi, I’m using Ubuntu 18.04 and after updating to OTP-24.0 yesterday i have this warning when I run “mix local.hex”:
14:57:30.512 [warn] ...
New
Student & New to elixir. Nice language.
I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible.
total = 10
while total != 0
...
New
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
Hi,
I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
Hey all,
I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
Other popular topics
Hi all,
Trying to get some more clarity over utc_datetime and naive_datetime for Ecto:
https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
You’re a programmer, so you don’t need spoon feeding with the conventional drivel about “this is an integer.” No. You need to know what’s...
New
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Hi,
I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
Hi everyone,
One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
I have a super simple question about elixir - how would I take a file like this
foo bar baz
and output a new file that enumerates th...
New
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New







