Кто-нибудь знает, почему следующая функция выдает эту ошибку на некоторых устройствах и как я могу ее исправить
"Ошибка: необходимо сначала вызвать 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
CreatePublicKeyCredentialRequest вызывает PhenotypeContext.setContext() ⇐ Android
Форум для тех, кто программирует под Android
1727112516
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
}
Подробнее здесь: [url]https://stackoverflow.com/questions/79015699/createpublickeycredentialrequest-throws-phenotypecontext-setcontext[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия