     # the access token as well.
     conn
     |> put_session(:current_user, user)
-    |> put_session(:access_token, token)
+    |> put_session(:access_token, token.access_token)
     |> redirect(to: "/")
   end
+end
 
-  defp strategy(conn), do: conn.private.oauth2_strategy
-
-  defp params(conn) do
-    %{redirect_uri: strategy(conn).redirect_uri}
-  end
-
-  defp token_params(params) do
-    Map.merge(%{headers: [{"Accept", "application/json"}]}, params)
-  end
-
-end

  """
  def callback(conn, %{"code" => code}) do
    # Exchange an auth code for an access token
    token = AuthCode.get_token!(strategy(conn), code, token_params(params(conn)))

    # Request the user's data with the access token
    user = AccessToken.get!(token, "/user")

    # Store the user in the session under `:current_user` and redirect to /.
    # In most cases, we'd probably just store the user's ID that can be used

defmodule OAuth2Example.AuthController do
  use OAuth2Example.Web, :controller

  plug :action

  @doc """
  This action is reached via `/auth` and redirects to the OAuth2 provider
  based on the chosen strategy.
  """
  def index(conn, _params) do
    redirect conn, external: GitHub.authorize_url!
  end

  @doc """
