Skip to content

Instantly share code, notes, and snippets.

@dllewellyn
Created July 2, 2020 08:01
Show Gist options
  • Save dllewellyn/ec872bd82a5ec06ec76a1e48d4eae86b to your computer and use it in GitHub Desktop.
Save dllewellyn/ec872bd82a5ec06ec76a1e48d4eae86b to your computer and use it in GitHub Desktop.
private fun signin() {
lifecycleScope.launch(errorHandler { signup() }) {
val result = oneTapClient.suspendBeginSignInRequest(buildSignInRequest())
loginResult.launch(
IntentSenderRequest.Builder(result.pendingIntent)
.build()
)
}
}
private fun buildSignInRequest() = BeginSignInRequest.builder()
.setPasswordRequestOptions(
BeginSignInRequest.PasswordRequestOptions.builder()
.setSupported(true)
.build()
)
.setGoogleIdTokenRequestOptions(
BeginSignInRequest.GoogleIdTokenRequestOptions.builder()
.setSupported(true)
// Your server's client ID, not your Android client ID.
.setServerClientId(getString(R.string.one_tap_client_id)) .setFilterByAuthorizedAccounts(true)
.build()
)
.build()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment