0

I was following this tutorial https://auth0.com/blog/elixir-and-phoenix-tutorial-build-an-authenticated-app/#Our-Phoenix-application-skeleton and everything was working fine until I tried to run it with the auth enabled. Now I keep getting this error:

** (RuntimeError) Expected to find settings under `config nil, Ueberauth.Strategy.Auth0.OAuth`, got nil. Check your config.exs.

Here is my config.exs...

  1 # and its dependencies with the aid of the Mix.Config module.
  2 #
  3 # This configuration file is loaded before any dependency and
  4 # is restricted to this project.
  5
  6 # General application configuration
  7 use Mix.Config
  8
  9 config :countdown,
 10   ecto_repos: [Countdown.Repo]
 11
 12 # Configures the endpoint
 13 config :countdown, CountdownWeb.Endpoint,
 14   url: [host: "localhost"],
 15   secret_key_base: "bur+iF3WjRBI22r3j/Yzh4O3//lVXhSnpyVZKFjBllvBKv5Neyh1zQKsLDLZuB9K",
 16   render_errors: [view: CountdownWeb.ErrorView, accepts: ~w(html json), layout: false],
 17   pubsub_server: Countdown.PubSub,
 18   live_view: [signing_salt: "waO+DlgX"]
 19
 20 # Configures Elixir's Logger
 21 config :logger, :console,
 22   format: "$time $metadata[$level] $message\n",
 23   metadata: [:request_id]
 24
 25 # Use Jason for JSON parsing in Phoenix
 26 config :phoenix, :json_library, Jason
 27
 28 # Configures Ueberauth
 29 config :ueberauth, Ueberauth,
 30   providers: [
 31     auth0: {Ueberauth.Strategy.Auth0, []},
 32   ]
 33
 34 # Import environment specific config. This must remain at the bottom
 35 # of this file so it overrides the configuration defined above.
 36 import_config "#{Mix.env()}.exs"

I also have...

+# Configures Ueberauth's Auth0 auth provider
+config :ueberauth, Ueberauth.Strategy.Auth0.OAuth,
+  domain: System.get_env("AUTH0_DOMAIN"),
+  client_id: System.get_env("AUTH0_CLIENT_ID"),
+  client_secret: System.get_env("AUTH0_CLIENT_SECRET")

in my config/dev.exs file.

I realize that this tutorial is very old but I couldn't find anything more recent. I looked at the Ueberauth_auth0 docs and they mention that you need to start ueberauth_auth0 before you start your application. I'm pretty new to Elixir/Phoenix and I'm not sure if that could be the issue or how to solve it? That seems to be the only thing that I am missing based on the tutorial, docs, and Ueberauth example app.

Any ideas?

Adam Millerchip
  • 20,844
  • 5
  • 51
  • 74
quarterpi
  • 833
  • 1
  • 6
  • 13
  • I assume you copy-pasted the config so the config is commented out, the error is telling you it can't find any of the env keys you need to set up. You can also type `printenv` command in the terminal and see do you have `AUTH0_DOMAIN`, `AUTH0_CLIENT_ID`, and `AUTH0_CLIENT_SECRET`. – copser Jul 07 '21 at 03:45
  • Please share your `config/config.exs` file. `config/dev.exs` won’t be magically load unless it’s loaded from `config/config.exs` explicitly. – Aleksei Matiushkin Jul 07 '21 at 09:50
  • @AlekseiMatiushkin Above is my config/config.exs and the relevent section of config/dev.exs. I'm new to Elixir and Phoenix so I don't know much but I understood that by setting `$MIX_ENV=dev` it would ensure that config/dev.exs would be included with config/config.exs. If that's not true, how do I include it? Do I `require` it? `alias` it? An example would be really helpful. – quarterpi Jul 07 '21 at 23:47
  • @copser Yes, I copy pasted the config. The comments were auto generated by Mix. I have verified that my env variables are present and set in my terminal session. It seems that perhaps they are not getting loaded properly by Ueberauth or whatever is responsible for loading them. – quarterpi Jul 07 '21 at 23:49
  • I also ran with `iex -S mix phx.server` to check what was returned by `System.get_env("AUTH0_DOMAIN")` etc... They were all set as expected. – quarterpi Jul 08 '21 at 00:01

0 Answers0