-
-
Save albka1986/ba693cc77bdd2e39ac65961db688c261 to your computer and use it in GitHub Desktop.
This file contains 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
class OktaAuthActivity : AppCompatActivity() { | |
private lateinit var mOktaAuth: OktaAppAuth | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
mOktaAuth = OktaAppAuth.getInstance(this) | |
setContentView(R.layout.activity_okta_auth) | |
mOktaAuth.init( | |
this, | |
object : OktaAppAuth.OktaAuthListener { | |
override fun onSuccess() { | |
toast("onSuccess") | |
findViewById<View>(R.id.auth_button).visibility = View.VISIBLE | |
findViewById<View>(R.id.loading_container).visibility = View.GONE | |
} | |
override fun onTokenFailure(p0: AuthorizationException) { | |
findViewById<View>(R.id.loading_container).visibility = View.GONE | |
toast("onTokenFailure") | |
} | |
} | |
) | |
val button = findViewById<View>(R.id.auth_button) as Button | |
button.setOnClickListener { | |
toast("Clicked") | |
val completionIntent = Intent(this, MainActivity::class.java) | |
val cancelIntent = Intent(this, OktaAuthActivity::class.java) | |
cancelIntent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP | |
mOktaAuth.login( | |
this, | |
PendingIntent.getActivity(this, 0, completionIntent, 0), | |
PendingIntent.getActivity(this, 0, cancelIntent, 0) | |
) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment