Easily implement the Google One Tap Sign-In Dialog into your Jetpack Compose app
OneTapSignIn
Easily implement the Google One Tap Sign-In Dialog into your Jetpack Compose app.
One Tap Sign In
Learn more about Google’s One Tap Sign In here: https://developers.google.com/identity/one-tap/android/overview
Installation
To use this One Tap Sign In component, add Jitpack as a repository in your project/build.gradle
or settings.gradle
file
// In project/build.gradle or settings.gradle
repositories {
...
maven("https://jitpack.io")
}
Then, in your module/build.gradle
, import the dependency
// In module/build.gradle
dependencies {
...
implementation("com.github.iideprived:OneTapSignIn:1.0.1")
}
Implementation
The implementation for the One Tap Sign In, using this component, is extremely simple. Simply store val oneTapState = rememberOneTapSignIn(...)
and open the menu when the user needs to sign in.
@Composable
fun LoginPage() {
val oneTapState = rememberOneTapSignIn("YOUR_CLIENT_ID") { credential ->
Log.d("OneTapSignIn", "Success!")
// TODO: Authenticate using something like Firebase
}
Button(onClick = { oneTapState.openMenu() } { Text("Sign In With Google") }
}