Implementing Google OAuth for Ueberauth and Phoenix

We'll start off simply enough by modifying our templates. We're going to add links to login with Google in both our login page and our new user account page. We'll start in lib/vocial_web/templates/session/new.html.eex:

    <br />    <%= link "Login with Google", to: "/auth/google" %>

And then modify our account creation page as well with a very similar link in lib/vocial_web/templates/user/new.html.eex:

<br /><%= link "Sign Up with Google", to: "/auth/google" %>

Finally, in the session controller (lib/vocial_web/controllers/session_controller.ex), we'll need to add a build_user_from_auth/1 that accounts for Google being the provider instead of Twitter. Google doesn't give us back a username, ...

Get Phoenix Web Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.