As a person using the @dwyl app to be more personally effective,
I do not want to stumble at the first hurdle trying to authenticate.
I don't expect to see unfriendly/unrecoverable error messages,
rather I expect to be able to recover from errors without drama.
At present our get_token/1 function is only following the "happy path":
|
def get_token(code) do |
|
body = Poison.encode!( |
|
%{ client_id: Application.get_env(:elixir_auth_google, :google_client_id), |
|
client_secret: Application.get_env(:elixir_auth_google, :google_client_secret), |
|
redirect_uri: Application.get_env(:elixir_auth_google, :google_redirect_uri), |
|
grant_type: "authorization_code", |
|
code: code |
|
}) |
|
|
|
@httpoison.post(@google_token_url, body) |
|
|> parse_body_response() |
|
end |
The callback function is parse_body_response/1 which does not handle the {:error, err}
|
defp parse_body_response({:ok, response}) do |
|
body = Map.get(response, :body) |
|
if body == nil do |
|
{:error, :no_body} |
|
else |
|
Poison.decode(body) |
|
end |
|
end |
This is fine during MVP because as early "dogfooding" users we are tolerant of the failure/errors.
But as soon as we ship and show the MVP to (friendly) alpha test users, we need to have this done.
Todo:
We do not need to handle the failures before we ship our MVP, let's come back to this when it's needed.
As a person using the @dwyl app to be more personally effective,
I do not want to stumble at the first hurdle trying to authenticate.
I don't expect to see unfriendly/unrecoverable error messages,
rather I expect to be able to recover from errors without drama.
At present our
get_token/1function is only following the "happy path":elixir-auth-google/lib/elixir_auth_google.ex
Lines 18 to 29 in 687fba5
The callback function is
parse_body_response/1which does not handle the{:error, err}elixir-auth-google/lib/elixir_auth_google.ex
Lines 38 to 45 in 687fba5
This is fine during MVP because as early "dogfooding" users we are tolerant of the failure/errors.
But as soon as we ship and show the MVP to (friendly) alpha test users, we need to have this done.
Todo:
casestatement to handle all the error conditions.templateto ensure that error conditions are displayed in a friendly way.README.md> How? section to inform people about error scenarios.We do not need to handle the failures before we ship our MVP, let's come back to this when it's needed.