Last active
September 18, 2018 20:07
-
-
Save adrianhall/807b2d8ced8e2b0a15dde001a45f23b7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Federate with Google authentication | |
| */ | |
| override fun federateWithGoogle(account: GoogleSignInAccount) { | |
| if (account.idToken != null) { | |
| Log.d(TAG, "Federating with Google") | |
| thread(start = true) { | |
| with(service.identityManager.underlyingProvider) { | |
| clear() | |
| withLogins(mapOf("accounts.google.com" to account.idToken)) | |
| refresh() | |
| } | |
| val user = User().apply { | |
| username = account.id!! | |
| tokens[TokenType.ACCESS_TOKEN] = account.idToken!! | |
| userAttributes["provider"] = "accounts.google.com" | |
| userAttributes["email"] = account.email!! | |
| } | |
| Log.d(TAG, "Federated result: ${service.identityManager.isUserSignedIn}") | |
| runOnUiThread { mCurrentUser.postValue(user) } | |
| } | |
| } else { | |
| Log.d(TAG, "Federating with Google (ID token is null, so nothing happening)") | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment