Skip to content

Commit 9ae213d

Browse files
author
Rohan Pujari
committed
Handle client side flow for google auth.
1 parent 0e4048d commit 9ae213d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/ueberauth/strategy/google.ex

+9-2
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,16 @@ defmodule Ueberauth.Strategy.Google do
4242
end
4343
end
4444

45+
@doc """
46+
Handles the callback for Google client side flow.
47+
"""
48+
def handle_callback!(%Plug.Conn{params: %{"token" => token}} = conn) do
49+
fetch_user(conn, OAuth2.AccessToken.new(token))
50+
end
51+
4552
@doc false
4653
def handle_callback!(conn) do
47-
set_errors!(conn, [error("missing_code", "No code received")])
54+
set_errors!(conn, [error("missing_code_or_token", "No code or token received")])
4855
end
4956

5057
@doc false
@@ -124,7 +131,7 @@ defmodule Ueberauth.Strategy.Google do
124131
resp = Ueberauth.Strategy.Google.OAuth.get(token, path)
125132

126133
case resp do
127-
{:ok, %OAuth2.Response{status_code: 401, body: _body}} ->
134+
{:error, %OAuth2.Response{status_code: 401, body: _body}} ->
128135
set_errors!(conn, [error("token", "unauthorized")])
129136
{:ok, %OAuth2.Response{status_code: status_code, body: user}} when status_code in 200..399 ->
130137
put_private(conn, :google_user, user)

0 commit comments

Comments
 (0)