CreatePublicKeyCredentialRequest вызывает PhenotypeContext.setContext()Android

Форум для тех, кто программирует под Android
Ответить
Anonymous
 CreatePublicKeyCredentialRequest вызывает PhenotypeContext.setContext()

Сообщение Anonymous »

Кто-нибудь знает, почему следующая функция выдает эту ошибку на некоторых устройствах и как я могу ее исправить
"Ошибка: необходимо сначала вызвать PhenotypeContext.setContext() типа w: android.credentials.CreateCredentialException.TYPE_UNKNOWN w obj: androidx.credentials.Exceptions.CreateCredentialUnknownException: необходимо сначала вызвать PhenotypeContext.setContext()"
suspend fun registerPasskey( jsonString: String): CreatePublicKeyCredentialResponse {
val credentialManager = CredentialManager.create(activity)

val json = JSONObject(jsonString)

val rpName = json.getJSONObject("rp").getString("name")
val rpId = json.getJSONObject("rp").getString("id")

val userVerification = json.getJSONObject("authenticatorSelection").getString("userVerification")
val requireResidentKey = json.getJSONObject("authenticatorSelection").getBoolean("requireResidentKey")
val residentKey = json.getJSONObject("authenticatorSelection").getString("residentKey")
val authenticatorAttachment = json.getJSONObject("authenticatorSelection").getString("authenticatorAttachment")

val userId = json.getJSONObject("user").getString("id")
val userName = json.getJSONObject("user").getString("name")
val userDisplayName = json.getJSONObject("user").getString("displayName")

val pubKeyCredParams = json.getJSONArray("pubKeyCredParams")

val attestation = json.getString("attestation")
val timeout = json.getLong("timeout")
val challenge = json.getString("challenge")

val excludeCredentials = json.getJSONArray("excludeCredentials")

val request = CreatePublicKeyCredentialRequest(
requestJson = JSONObject().apply {
put("rp", JSONObject().apply {
put("name", rpName)
put("id", rpId)
})
put("user", JSONObject().apply {
put("id", userId)
put("name", userName)
put("displayName", userDisplayName)
})
put("challenge", challenge)
put("pubKeyCredParams", pubKeyCredParams)
put("timeout", timeout)
put("excludeCredentials", excludeCredentials)
put("authenticatorSelection", JSONObject().apply {
put("authenticatorAttachment", authenticatorAttachment)
put("requireResidentKey", requireResidentKey)
put("residentKey", residentKey)
put("userVerification", userVerification)
})
put("attestation", attestation)
}.toString()
)

return credentialManager.createCredential(activity, request) as CreatePublicKeyCredentialResponse
}


Подробнее здесь: https://stackoverflow.com/questions/790 ... setcontext
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Android»