Skip to content

Commit

Permalink
Adds initial google oauth integration setup
Browse files Browse the repository at this point in the history
  • Loading branch information
nburkley committed Sep 12, 2016
1 parent 8d4f63a commit 45f1354
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,9 @@ config :ueberauth, Ueberauth,
slack: { Ueberauth.Strategy.Slack, [
default_scope: "bot,commands,users:read,team:read"
]
},
google: { Ueberauth.Strategy.Google, [
default_scope: "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/analytics"
]
}
]
4 changes: 4 additions & 0 deletions config/dev.secret.exs.sample
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ config :espi_dni, EspiDni.Plugs.RequireSlackToken,
config :ueberauth, Ueberauth.Strategy.Slack.OAuth,
client_id: "slack-client-id",
client_secret: "slack-client-secret"

config :ueberauth, Ueberauth.Strategy.Google.OAuth,
client_id: "google-client-id",
client_secret: "google-client-secret"
7 changes: 6 additions & 1 deletion web/controllers/auth_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ defmodule EspiDni.AuthController do
|> redirect(to: "/")
end

def callback(%{assigns: %{ueberauth_auth: auth}} = conn, _params) do
def callback(%{assigns: %{ueberauth_auth: auth}} = conn, %{"provider" => "slack"} = _params) do
case AuthHandler.init_from_auth(auth) do
{:ok, team, user} ->
conn
Expand All @@ -36,6 +36,11 @@ defmodule EspiDni.AuthController do
end
end

def callback(%{assigns: %{ueberauth_auth: auth}} = conn, %{"provider" => "google"} = _params) do
conn
|> put_flash(:info, "Successfully authenticated with google.")
end

defp start_bot(conn) do
team = get_session(conn, :current_team)
EspiDni.BotSupervisor.start_bot(team.token)
Expand Down

0 comments on commit 45f1354

Please sign in to comment.