Any clear guide on how to do Google sign-in with Lock for Android

Hello everyone,

I am having trouble understanding how Lock for Android can accomplish Google sign-in. Our requirement is that we want to add a “Sign-in with Google” button on our app. Once the user clicks it and completes sign-in with Google, the user should automatically be registered on our app, which currently uses Auth0. Having a look at the Lock.Android Github repo, the sample app doesn’t really do anything (clicking on the button shows me failure screens). I also stumbled upon this article, but comparing it with Google’s guide for integrating sign-in, it’s completely unclear how the two work together. The readme in the Lock for Android Github repo doesn’t have a clear step-by-step guide. Anyone here have experience integrating it successfully or am I missing something?

Hi there @admdizon welcome back!

Is there a particular reason you are looking to use a native flow as opposed to browser based? The reason I ask is because the browser based flow is generally recommended and also makes it super easy to implement a social login like Google. See this article for more information regarding native vs. browser.

I’m unfortunately unaware of any other guide, nor have I implemented this myself. However, I can attest to these samples and the Auth0.Android SDK. Using this approach (WebAuthProvider/Universal Login) allows you to configure the Google integration in your Auth0 dashboard and toggle it on in the app settings directly.

Let us know!

Hi @tyf , thanks for replying. I’ve read that the browser based flow is recommended, but most apps have native login options–they have options for logging in via email, or login via Facebook/Google. If I understand Lock’s usecase, using it should display an Activity that contains Google or Facebook sign-in options right?

Thank you also for linking to those samples, I will check those out.

Hi @tyf, so to clarify, the sample code you linked should be followed if I want to do a sign-in with Google? I saw this post in this forum that uses WebAuthProvider as well. But I also saw another post here in this forum saying native Google sign-in is not supported. Can you clarify what this means?

edit: I think I understand what is being meant by “native Google sign-in is not supported”–it just means that Google sign-in via embedded login (presumably with loginWithNativeSocialToken) is still not supported.

So now I tried tinkering with the sample repo and used our existing app’s client ID and domain (in development environment, of course). And specified that I want to redirect to Google sign-in via withConnection("google-oauth2"):

WebAuthProvider.login(account)
            .withConnection("google-oauth2")
           // ...

and sure enough a browser opens that redirects to Google, but I am greeted with an error 400: redirect_url_mismatch. The error seems to indicate that we need to add a redirect URI somewhere in the Google Cloud Console. Am I in the right direction?

Edit: I will just open another topic for my questions regarding WebAuthProvider. Will be marking @tyf 's answer as the solution.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.