in Fido2/app/src/main/java/com/google/android/gms/identity/sample/fido2/api/AuthApi.kt [241:277]
suspend fun signinResponse(
sessionId: String,
credential: PublicKeyCredential
): ApiResult<List<Credential>> {
val rawId = credential.rawId.toBase64()
val response = credential.response as AuthenticatorAssertionResponse
val call = client.newCall(
Request.Builder()
.url("$BASE_URL/signinResponse")
.addHeader("Cookie", formatCookie(sessionId))
.method("POST", jsonRequestBody {
name("id").value(rawId)
name("type").value(PublicKeyCredentialType.PUBLIC_KEY.toString())
name("rawId").value(rawId)
name("response").objectValue {
name("clientDataJSON").value(
response.clientDataJSON.toBase64()
)
name("authenticatorData").value(
response.authenticatorData.toBase64()
)
name("signature").value(
response.signature.toBase64()
)
name("userHandle").value(
response.userHandle?.toBase64() ?: ""
)
}
})
.build()
)
val apiResponse = call.await()
return apiResponse.result("Error calling /signingResponse") {
parseUserCredentials(body ?: throw ApiException("Empty response from /signinResponse"))
}
}