elixir_auth_google v0.0.1 ElixirAuthGoogle

Minimalist Google OAuth Authentication for Elixir Apps. Extensively tested, documented, maintained and in active use in production.

Link to this section Summary

Functions

generate_oauth_url/0 creates the Google OAuth2 URL with client_id, scope and redirect_uri which is the URL Google will redirect to when auth is successful. This is the URL you need to use for your "Login with Google" button. See step 5 of the instructions.

get_token/1 encodes the secret keys and authorization code returned by Google and issues an HTTP request to get a person's profile data.

get_user_profile/1 requests the Google User's userinfo profile data providing the access_token received in the get_token/1 above. invokes parse_body_response/1 to decode the JSON data.

parse_body_response/1 parses the response returned by Google so your app can use the resulting JSON.

Link to this section Functions

Link to this function

generate_oauth_url()

generate_oauth_url() :: String.t()

generate_oauth_url/0 creates the Google OAuth2 URL with client_id, scope and redirect_uri which is the URL Google will redirect to when auth is successful. This is the URL you need to use for your "Login with Google" button. See step 5 of the instructions.

Link to this function

get_token(code)

get_token(String.t()) :: String.t()

get_token/1 encodes the secret keys and authorization code returned by Google and issues an HTTP request to get a person's profile data.

TODO: we still need to handle the various failure conditions >> issues/16

Link to this function

get_user_profile(token)

get_user_profile(String.t()) :: String.t()

get_user_profile/1 requests the Google User's userinfo profile data providing the access_token received in the get_token/1 above. invokes parse_body_response/1 to decode the JSON data.

TODO: we still need to handle the various failure conditions >> issues/16 At this point the types of errors we expect are HTTP 40x/50x responses.

Link to this function

parse_body_response(arg)

parse_body_response({atom(), String.t()}) :: String.t()

parse_body_response/1 parses the response returned by Google so your app can use the resulting JSON.