@@ -2,6 +2,7 @@ package com.auth0.sample
22
33import android.os.Bundle
44import android.os.CancellationSignal
5+ import android.util.Log
56import android.view.LayoutInflater
67import android.view.View
78import android.view.ViewGroup
@@ -50,6 +51,11 @@ import java.util.concurrent.Executors
5051 */
5152class DatabaseLoginFragment : Fragment () {
5253
54+ companion object {
55+ private const val TAG = " Auth0CrashRepro"
56+ private const val SDK_VERSION = " 3.13.0 (OAEP)"
57+ }
58+
5359 private val scope = " openid profile email read:current_user update:current_user_metadata"
5460
5561 private val account: Auth0 by lazy {
@@ -122,6 +128,8 @@ class DatabaseLoginFragment : Fragment() {
122128 inflater : LayoutInflater , container : ViewGroup ? , savedInstanceState : Bundle ?
123129 ): View {
124130 val binding = FragmentDatabaseLoginBinding .inflate(inflater, container, false )
131+ binding.tvSdkVersion.text = " SDK: $SDK_VERSION "
132+ Log .i(TAG , " === App started with SDK version: $SDK_VERSION ===" )
125133 binding.btLogin.setOnClickListener {
126134 val email = binding.textEmail.text.toString()
127135 val password = binding.textPassword.text.toString()
@@ -215,39 +223,70 @@ class DatabaseLoginFragment : Fragment() {
215223 }
216224
217225 private suspend fun dbLoginAsync (email : String , password : String ) {
226+ Log .i(TAG , " >>> dbLoginAsync() called with email=$email " )
218227 try {
219228 val result =
220229 authenticationApiClient.login(email, password, " Username-Password-Authentication" )
221230 .validateClaims()
222231 .addParameter(" scope" , scope)
223232 .addParameter(" audience" , audience)
224233 .await()
225- credentialsManager.saveCredentials(result)
234+ Log .i(TAG , " >>> dbLoginAsync SUCCESS - got credentials for ${result.user.name} " )
235+ Log .i(TAG , " >>> Calling credentialsManager.saveCredentials()..." )
236+ try {
237+ credentialsManager.saveCredentials(result)
238+ Log .i(TAG , " >>> credentialsManager.saveCredentials() OK" )
239+ } catch (e: Exception ) {
240+ Log .e(TAG , " >>> credentialsManager.saveCredentials() FAILED" , e)
241+ }
242+ Log .i(TAG , " >>> Calling secureCredentialsManager.saveCredentials()..." )
243+ try {
244+ secureCredentialsManager.saveCredentials(result)
245+ Log .i(TAG , " >>> secureCredentialsManager.saveCredentials() OK" )
246+ } catch (e: Exception ) {
247+ Log .e(TAG , " >>> secureCredentialsManager.saveCredentials() FAILED" , e)
248+ }
226249 Snackbar .make(
227250 requireView(),
228251 " Hello ${result.user.name} " ,
229252 Snackbar .LENGTH_LONG
230253 )
231254 .show()
232255 } catch (error: AuthenticationException ) {
256+ Log .e(TAG , " >>> dbLoginAsync FAILED" , error)
233257 Snackbar .make(requireView(), error.getDescription(), Snackbar .LENGTH_LONG ).show()
234258 }
235259 }
236260
237261 private fun dbLogin (email : String , password : String ) {
262+ Log .i(TAG , " >>> dbLogin() called with email=$email " )
238263 authenticationApiClient.login(email, password, " Username-Password-Authentication" )
239264 .validateClaims()
240265 .addParameter(" scope" , scope)
241266 .addParameter(" audience" , audience)
242- // Additional customization to the request goes here
243267 .start(object : Callback <Credentials , AuthenticationException > {
244268 override fun onFailure (error : AuthenticationException ) {
269+ Log .e(TAG , " >>> dbLogin FAILED" , error)
245270 Snackbar .make(requireView(), error.getDescription(), Snackbar .LENGTH_LONG )
246271 .show()
247272 }
248273
249274 override fun onSuccess (result : Credentials ) {
250- credentialsManager.saveCredentials(result)
275+ Log .i(TAG , " >>> dbLogin SUCCESS - got credentials for ${result.user.name} " )
276+ Log .i(TAG , " >>> Calling credentialsManager.saveCredentials()..." )
277+ try {
278+ credentialsManager.saveCredentials(result)
279+ Log .i(TAG , " >>> credentialsManager.saveCredentials() OK" )
280+ } catch (e: Exception ) {
281+ Log .e(TAG , " >>> credentialsManager.saveCredentials() FAILED" , e)
282+ }
283+ Log .i(TAG , " >>> Calling secureCredentialsManager.saveCredentials()..." )
284+ try {
285+ secureCredentialsManager.saveCredentials(result)
286+ Log .i(TAG , " >>> secureCredentialsManager.saveCredentials() OK" )
287+ } catch (e: Exception ) {
288+ Log .e(TAG , " >>> secureCredentialsManager.saveCredentials() FAILED" , e)
289+ }
251290 Snackbar .make(
252291 requireView(),
253292 " Hello ${result.user.name} " ,
@@ -258,14 +297,28 @@ class DatabaseLoginFragment : Fragment() {
258297 }
259298
260299 private fun webAuth () {
300+ Log .i(TAG , " >>> webAuth() called - starting browser login" )
261301 WebAuthProvider .login(account)
262302 .withScheme(getString(R .string.com_auth0_scheme))
263303 .withAudience(audience)
264304 .withScope(scope)
265305 .start(requireContext(), object : Callback <Credentials , AuthenticationException > {
266306 override fun onSuccess (result : Credentials ) {
267- credentialsManager.saveCredentials(result)
268- secureCredentialsManager.saveCredentials(result)
307+ Log .i(TAG , " >>> webAuth SUCCESS - got credentials for ${result.user.name} " )
308+ Log .i(TAG , " >>> Calling credentialsManager.saveCredentials()..." )
309+ try {
310+ credentialsManager.saveCredentials(result)
311+ Log .i(TAG , " >>> credentialsManager.saveCredentials() OK" )
312+ } catch (e: Exception ) {
313+ Log .e(TAG , " >>> credentialsManager.saveCredentials() FAILED" , e)
314+ }
315+ Log .i(TAG , " >>> Calling secureCredentialsManager.saveCredentials()..." )
316+ try {
317+ secureCredentialsManager.saveCredentials(result)
318+ Log .i(TAG , " >>> secureCredentialsManager.saveCredentials() OK" )
319+ } catch (e: Exception ) {
320+ Log .e(TAG , " >>> secureCredentialsManager.saveCredentials() FAILED" , e)
321+ }
269322 Snackbar .make(
270323 requireView(),
271324 " Hello ${result.user.name} " ,
@@ -274,6 +327,7 @@ class DatabaseLoginFragment : Fragment() {
274327 }
275328
276329 override fun onFailure (error : AuthenticationException ) {
330+ Log .e(TAG , " >>> webAuth FAILED" , error)
277331 val message =
278332 if (error.isCanceled)
279333 " Browser was closed"
0 commit comments