-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: Add Support for Google Identity #53
Comments
Hi @astroTANSAN, indeed this is a new service from Google. It’s a re-branding of their OAuth/Single-signon service that billions of people are already familiar with & actively using. |
Should I close this issue and create a feature request ticket? |
@astroTANSAN no need to close and re-create. |
Just had a quick look at the API/SDK. The "One Tap" feature is cool but requires including their |
Okay. I went ahead and edited the post.
I was mainly looking at this page for verifying with a ID token: https://developers.google.com/identity/gsi/web/guides/verify-google-id-token |
I looked at One Tap this weekend. You don't need JS.
<script src="https://accounts.google.com/gsi/client" async defer></script>
<div id="g_id_onload"
data-client_id={System.get_env("GOOGLE_CLIENT_ID")}
data-login_uri="http://localhost:4000/auth/one_tap" <----- POST endpoint
data-auto_prompt="true"
>
</div>
<div class="g_id_signin"
data-type="standard"
data-size="large"
data-theme="outline"
data-text="sign_in_with"
data-shape="rectangular"
data-logo_alignment="left">
</div> Then in your router: pipeline :api do
plug :accepts, ["json"]
post "/auth/one_tap", MyAppWeb.OneTapController, :handle
end and the controller: use LiveMapWeb, :controller
defp parse(%{"email" => email, "name" => name, "picture" => picture} = _data) do
%{email: email, name: name, picture: picture}
end
def handle(conn, %{"credential" => credential}) do
("https://oauth2.googleapis.com/tokeninfo?id_token=" <> credential)
|> HTTPoison.get!()
|> Map.get(:body)
|> Jason.decode!()
|> then(&parse/1)
end 🚀 OK, this is cheating because I used a dev endpoint to decode the token. |
Google is discontinuing Google Sign-In for their new identity services: https://developers.googleblog.com/2021/08/gsi-jsweb-deprecation.html
The new API seems to be https://developers.google.com/identity this service for signing in. The server side verification requires sending the idToken and the client ID (https://developers.google.com/identity/gsi/web/guides/verify-google-id-token).
The text was updated successfully, but these errors were encountered: