identity-samples
identity-samples copied to clipboard
Documentation Error, CredentialManager method specifically in credentialManager.createCredential(request, requireActivity()) as CreatePasswordResponse
trafficstars
Method expect :
public open suspend fun createCredential(
context: Context,
request: CreateCredentialRequest
): CreateCredentialResponse
Registers a user credential that can be used to authenticate the user to the app in the future.
The execution potentially launches framework UI flows for a user to view their registration options, grant consent, etc.
Params:
context - the context used to launch any UI needed; use an activity context to make sure the UI will be launched within the same task stack
request - the request for creating the credential
Throws:
CreateCredentialException - If the request fails
Incorrect code :
private suspend fun createPassword() {
//TODO : CreatePasswordRequest with entered username and password
val request = CreatePasswordRequest(
binding.username.text.toString(),
binding.password.text.toString()
)
//TODO : Create credential with created password request
try {
credentialManager.createCredential(request, requireActivity()) as CreatePasswordResponse
} catch (e: Exception) {
Log.e("Auth", " Exception Message : " + e.message)
}
}
**Correct code should look :**
private suspend fun createPassword() {
//TODO : CreatePasswordRequest with entered username and password
val request = CreatePasswordRequest(
binding.username.text.toString(),
binding.password.text.toString()
)
//TODO : Create credential with created password request
try {
credentialManager.createCredential(requireActivity(), request) as CreatePasswordResponse
} catch (e: Exception) {
Log.e("Auth", " Exception Message : " + e.message)
}
}
Thank you for the correction. I would have been stuck pretty bad.
Hi tank you for sharing, We have already updated the code sometime back. Please check and let me know if there's an issue or I missed anything? Feel free to reopen