Skip to content

Instantly share code, notes, and snippets.

@adrianhall
Created September 14, 2018 18:02
Show Gist options
  • Save adrianhall/0be17cc1500922da48dd1fba0c490004 to your computer and use it in GitHub Desktop.
Save adrianhall/0be17cc1500922da48dd1fba0c490004 to your computer and use it in GitHub Desktop.
/**
* Federate with Facebook authentication
*/
override fun federateWithFacebook(accessToken: AccessToken) {
Log.d(TAG, "Federating with Facebook")
thread(start = true) {
with(service.identityManager.underlyingProvider) {
clear()
withLogins(mapOf("graph.facebook.com" to accessToken.token))
refresh()
}
val user = User().apply {
username = accessToken.userId
tokens[TokenType.ACCESS_TOKEN] = accessToken.token
userAttributes["provider"] = "graph.facebook.com"
}
Log.d(TAG, "Federated result: ${service.identityManager.isUserSignedIn}")
runOnUiThread { mCurrentUser.postValue(user) }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment