New to Elixir Phoenix framework, enjoying the framework till now.
Am trying to setup auth module with guardian deps for generating access and refresh token, however I receive below error message when I call the controller to generate tokens.
dev.exs
config :appPhoenixServer, AppPhoenixServerWeb.Guardian,
issuer: "appPhoenixServer",
secret_key: "ons1dYYyQjmNEefkIB9rU0cF1aD7ejvYkAcyl9A7H+nfyKNpIMeVTHu2KZUyP9D0"
router.ex
scope "/v1" do
pipe_through :api
post "/auth", AuthController, :auth
end
auth_token.ex
defmodule AppPhoenixServer.AuthToken do
alias AppPhoenixServer.Guardian
def generate_tokens(account) do
{:ok, access_token, _claims} = Guardian.encode_and_sign(account, %{}, token_type: :access)
{:ok, refresh_token, _claims} = Guardian.encode_and_sign(account, %{}, token_type: :refresh)
%{
access_token: access_token,
refresh_token: refresh_token
}
end
end
Error I receive when I call the controller class
[error] ** (MatchError) no match of right hand side value: {:error, :secret_not_found}
(appPhoenixServer 0.1.0) lib/appPhoenixServer/auth_token.ex:7: AppServer.AuthToken.generate_tokens/1