initAuthenticate method
Initiates the authentication by asking for a challenge.
Implementation
@override
Future<AuthenticationInitResponse> initAuthenticate(
CorbadoRequest request,
) async {
try {
final result = await UsersApi(_client)
.passKeyLoginStart(PassKeyLoginStartReq(username: request.email));
if (result == null) {
throw Exception('An unknown error occured during the Corbado API call');
}
if (result.data.challenge.isEmpty) {
throw NoPasskeyForDeviceException();
}
final json = jsonDecode(result.data.challenge) as Map<String, dynamic>;
final typed = CorbadoAuthenticationInitResponse.fromJson(json);
return typed.toAuthenticationInitResponse();
} on ApiException catch (e) {
throw ExceptionFactory.fromBackendMessage(
'passKeyAuthenticateStart',
e.message ?? '',
);
}
}