Skip to content

Instantly share code, notes, and snippets.

@adrianhall
Last active September 18, 2018 20:09
Show Gist options
  • Save adrianhall/fd74f1d5b3e0d733b7879546e533fdc9 to your computer and use it in GitHub Desktop.
Save adrianhall/fd74f1d5b3e0d733b7879546e533fdc9 to your computer and use it in GitHub Desktop.
// Check to see if Google is authenticated - if it is, then federate with Google
val googleAccount = GoogleSignIn.getLastSignedInAccount(context)
if (googleAccount != null) {
Log.d(TAG, "Google Signed In Account found - account=${googleAccount.toJson()} ")
thread(start = true) {
try {
val googleOptions = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(context.getString(R.string.google_client))
.requestEmail()
.build()
GoogleSignIn.getClient(context, googleOptions).silentSignIn().continueWith {
val account = it.getResult(ApiException::class.java)
federateWithGoogle(account)
}
} catch (error: ApiException) {
// Silent ignore
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment