Skip to content

Instantly share code, notes, and snippets.

@adrianhall
Last active September 18, 2018 21:50
Show Gist options
  • Select an option

  • Save adrianhall/a1941b163864a78b796e8e790cfad6ed to your computer and use it in GitHub Desktop.

Select an option

Save adrianhall/a1941b163864a78b796e8e790cfad6ed to your computer and use it in GitHub Desktop.
// Configure the Auth0 requirements
val auth0Settings = Auth0(this).apply {
isOIDCConformant = true
}
val audience = String.format("https://%s/userinfo", resources.getString(R.string.com_auth0_domain))
loginFormAuth0LoginButton.onClick {
WebAuthProvider.init(auth0Settings)
.withAudience(audience)
.start(this@AuthenticatorActivity, object : AuthCallback {
override fun onSuccess(credentials: Credentials) {
runOnUiThread { toast("Auth0 Authenticated Successfully") }
Log.d(TAG, "ID Token = ${credentials.idToken}")
}
override fun onFailure(dialog: Dialog) {
Log.d(TAG, "Auth0 Error displayed in dialog")
runOnUiThread { dialog.show() }
}
override fun onFailure(exception: AuthenticationException?) {
runOnUiThread { toast("Auth0 Authentication Failed") }
Log.e(TAG, "Auth0 Error: ${exception?.localizedMessage}")
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment