joken_jwks
joken_jwks copied to clipboard
1st argument: the table identifier does not refer to an existing ETS table
Hi guys! I need your help! I am trying to verify idToken from google user(google sign in) Here is my implementation
google_strategy.ex
defmodule MyApp.Account.GoogleStrategy do
use JokenJwks.DefaultStrategyTemplate
def init_opts(opts) do
url = "https://www.googleapis.com/oauth2/v3/certs"
Keyword.merge(opts, jwks_url: url)
end
end
google_token.ex
defmodule MyApp.Account.GoogleToken do
use Joken.Config
add_hook(JokenJwks, strategy: MyApp.Account.GoogleStrategy)
def token_config do
auds = [
.....................
]
# Validate from the token
default_claims()
|> add_claim("iss", nil, &(&1 == "https://accounts.google.com"))
|> add_claim(
"aud",
nil,
&Enum.member?(auds, &1)
)
end
end
And trying
GoogleToken.verify_and_validate(id_token)
And got this error.
(stdlib 3.15.1) :ets.lookup(MyApp.Account.GoogleStrategy.EtsCache, :signers)
(my_app 0.1.0) lib/my_app/account/google_strategy.ex:2: MyApp.Account.GoogleStrategy.EtsCache.get_signers/0
(my_app 0.1.0) lib/my_app/account/google_strategy.ex:2: MyApp.Account.GoogleStrategy.match_signer_for_kid/2
(joken_jwks 1.4.1) lib/joken_jwks.ex:54: JokenJwks.before_verify/2
(joken 2.3.0) lib/joken/hooks.ex:199: anonymous fn/3 in Joken.Hooks.run_before_hook/3
(elixir 1.13.1) lib/enum.ex:4475: Enumerable.List.reduce/3
(elixir 1.13.1) lib/enum.ex:2442: Enum.reduce_while/3
(joken 2.3.0) lib/joken/hooks.ex:196: Joken.Hooks.run_before_hook/3
(joken 2.3.0) lib/joken.ex:253: Joken.verify/3
(joken 2.3.0) lib/joken.ex:299: Joken.verify_and_validate/5
I am using joken_jwks 1.4 What am I missing?
Did you add MyApp.Account.GoogleStrategy to your children list in the MyApp.Application module?
Unless you start it, the :ets.new() won't be run, meaning :ets.lookup won't work, because the table isn't created yet.
Thanks once again @lovebes ! I will close this for now for missing response here. If the problem still exists and is reproducible, please feel free to re-open :)