Phoenix Tokens in 1.3rc

I get the following with 1.3rc.

Any insight?

Perhaps my upgrade went awry…

iex(5)> token = Phoenix.Token.sign(Hello.Web.Endpoint, "user", 1)
** (ArgumentError) argument error
      (crypto) :crypto.hmac_nif(:sha256, nil, <<117, 115, 101, 114, 0, 0, 0, 1>>)
      (crypto) crypto.erl:766: :crypto.hmac/6
        (plug) lib/plug/crypto/key_generator.ex:64: Plug.Crypto.KeyGenerator.generate/7
        (plug) lib/plug/crypto/key_generator.ex:50: Plug.Crypto.KeyGenerator.with_cache/3
     (phoenix) lib/phoenix/token.ex:109: Phoenix.Token.sign/4

it seems like it cannot get secret from Hello.Web.Endpoint

please make sure secret_key_base is set to something in your config/config.exs like

config :hello, Hello.Web.Endpoint,
  secret_key_base: "akjsdfhgkajsdhfg",

or it might be something else …


As @idi527 said, looks like you don’t have the necessary configuration for the Hello.Web.Endpoint module. Perhaps you renamed the module and forgot to bump the config in config/*.exs? I have improved the error message on master in this case, but the solution is as @idi527 layer out. Let us know if that gets you moving!


Yup you got it in one! Thanks guys : )

1 Like