Skip to content

Commit

Permalink
remove debugging. function based dependency injection works. fixes #35
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed Apr 2, 2020
1 parent 8be0173 commit f5dcf36
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
10 changes: 3 additions & 7 deletions lib/elixir_auth_google.ex
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,16 @@ defmodule ElixirAuthGoogle do
"""
@spec get_token(String.t, Map) :: String.t
def get_token(code, conn) do
env = Mix.env()
IO.inspect(env, label: "env")
httpoison = inject_poison()
body = Poison.encode!(
%{ client_id: System.get_env("GOOGLE_CLIENT_ID"),
client_secret: System.get_env("GOOGLE_CLIENT_SECRET"),
redirect_uri: generate_redirect_uri(conn),
grant_type: "authorization_code",
code: code
})
IO.inspect(body, label: "body")
httpoison.post(@google_token_url, body)
inject_poison().post(@google_token_url, body)
|> parse_body_response()
|> IO.inspect(label: "get_token() response")
# |> IO.inspect(label: "get_token() response")
end

@doc """
Expand All @@ -92,7 +88,7 @@ defmodule ElixirAuthGoogle do
"#{@google_user_profile}?access_token=#{token}"
|> httpoison.get()
|> parse_body_response()
|> IO.inspect(label: "get_user_profile() response")
# |> IO.inspect(label: "get_user_profile() response")
end

@doc """
Expand Down
6 changes: 3 additions & 3 deletions lib/httpoison_mock.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ defmodule ElixirAuthGoogle.HTTPoisonMock do
Obviously, don't invoke it from your App unless you want people to see fails.
"""
def get("https://www.googleapis.com/oauth2/v3/userinfo?access_token=wrong_token") do
IO.inspect("HTTPoisonMock.get access_token=wrong_token")
# IO.inspect("HTTPoisonMock.get access_token=wrong_token")
{:error, :bad_request}
end

@doc """
get/1 using a dummy _url to test body decoding.
"""
def get(_url) do
IO.inspect("HTTPoisonMock.get %{name: dwyl}")
# IO.inspect("HTTPoisonMock.get %{name: dwyl}")
{:ok, %{body: Poison.encode!(
%{
email: "nelson@gmail.com",
Expand All @@ -36,7 +36,7 @@ defmodule ElixirAuthGoogle.HTTPoisonMock do
post/2 passing in dummy _url & _body to test return of access_token.
"""
def post(_url, _body) do
IO.inspect("HTTPoisonMock.post %{ccess_token: token1}")
# IO.inspect("HTTPoisonMock.post %{ccess_token: token1}")
{:ok, %{body: Poison.encode!(%{access_token: "token1"})}}
end
end
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ defmodule ElixirAuthGoogle.MixProject do
use Mix.Project

@description "Minimalist Google OAuth Authentication for Elixir Apps"
@version "1.1.4"
@version "1.1.5"

def project do
[
Expand Down

0 comments on commit f5dcf36

Please sign in to comment.