Skip to content
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

Open
tansanDOTeth opened this issue Jan 1, 2022 · 6 comments
Open

Feat: Add Support for Google Identity #53

tansanDOTeth opened this issue Jan 1, 2022 · 6 comments
Labels
enhancement New feature or request help wanted Extra attention is needed research Research required; be specific technical

Comments

@tansanDOTeth
Copy link

tansanDOTeth commented Jan 1, 2022

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).

@nelsonic
Copy link
Member

nelsonic commented Jan 1, 2022

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.
We could add support for this in the future if enough people request it. 💭

@tansanDOTeth
Copy link
Author

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. We could add support for this in the future if enough people request it. 💭

Should I close this issue and create a feature request ticket?

@nelsonic
Copy link
Member

nelsonic commented Jan 1, 2022

@astroTANSAN no need to close and re-create.
Let's just reword the title and add it to the backlog.
Do you need this for something you're working on? 💭

@nelsonic nelsonic changed the title Does this work with Google Identity? Feat: Add Support for Google Identity Jan 1, 2022
@nelsonic nelsonic added enhancement New feature or request help wanted Extra attention is needed research Research required; be specific technical labels Jan 1, 2022
@nelsonic
Copy link
Member

nelsonic commented Jan 1, 2022

Just had a quick look at the API/SDK. The "One Tap" feature is cool but requires including their JavaScript SDK in your web app. There's definitely a use-case for it; streamlines auth for people who are signed into their Google Account.
But it appears to require writing some JS code to handle the requests ... which I'm not averse to. but we would need to get this feature request "up-voted" by a few people using our auth/product to justify investing the time. 💭

@tansanDOTeth
Copy link
Author

@astroTANSAN no need to close and re-create. Let's just reword the title and add it to the backlog. Do you need this for something you're working on? 💭

Okay. I went ahead and edited the post.

Just had a quick look at the API/SDK. The "One Tap" feature is cool but requires including their JavaScript SDK in your web app. There's definitely a use-case for it; streamlines auth for people who are signed into their Google Account. But it appears to require writing some JS code to handle the requests ... which I'm not averse to. but we would need to get this feature request "up-voted" by a few people using our auth/product to justify investing the time. 💭

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

@ndrean
Copy link
Contributor

ndrean commented Oct 18, 2022

I looked at One Tap this weekend. You don't need JS.

  • add the Google button and an endpoint for a POST request
<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.
I will propose something; in short, it seems you need to download Googles' PEM on
a regular basis to decode the JWT. Probably not totally straightforward.

ndrean pushed a commit to ndrean/elixir-auth-google that referenced this issue Oct 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed research Research required; be specific technical
Projects
None yet
Development

No branches or pull requests

3 participants