-
-
Notifications
You must be signed in to change notification settings - Fork 12
Closed
Description
This is running on a Kobweb API call under JVM, so there could be some different initialisation in there.
Stepping through the code, it appears that the enqueueRefreshTokenCall is hanging on this line:
this@FirebaseAuth.user = user
It goes through the successful response and then sets up the refresh token call...
override fun onResponse(call: Call, response: Response) {
if (!response.isSuccessful) {
source.setException(
createAuthInvalidUserException("verifyPassword", request, response)
)
} else {
val body = response.body()!!.use { it.string() }
val user = FirebaseUserImpl(app, jsonParser.parseToJsonElement(body).jsonObject)
refreshToken(user, source) { AuthResult { it } }
}
}
Which calls the enqueueRefreshTokenCall...
internal fun <T> refreshToken(user: FirebaseUserImpl, source: TaskCompletionSource<T>, map: (user: FirebaseUserImpl) -> T?) {
refreshSource = refreshSource
.takeUnless { it.task.isComplete }
?: enqueueRefreshTokenCall(user)
refreshSource.task.addOnSuccessListener { source.setResult(map(it)) }
refreshSource.task.addOnFailureListener { source.setException(it) }
}
Which gets back a successful response with the token, but the this@FirebaseAuth.user = user line never completes, so the source.setResult call never occurs. Hence the hang.
@Throws(IOException::class)
override fun onResponse(call: Call, response: Response) {
val body = response.body()?.use { it.string() }
if (!response.isSuccessful) {
signOutAndThrowInvalidUserException(body.orEmpty(), "token API returned an error: $body")
} else {
jsonParser.parseToJsonElement(body!!).jsonObject.apply {
val user = FirebaseUserImpl(app, this, user.isAnonymous)
if (user.claims["aud"] != app.options.projectId) {
signOutAndThrowInvalidUserException(
user.claims.toString(),
"Project ID's do not match ${user.claims["aud"]} != ${app.options.projectId}"
)
} else {
this@FirebaseAuth.user = user
source.setResult(user)
}
}
}
}
My Kobweb code is actually using firebase-kotlin-sdk 2.1.0 and the latest Kobweb with Kotlin 2.
Metadata
Metadata
Assignees
Labels
No labels