public static async Task AuthenticateAsync(IHidDevice hidDevice, DeviceRegistration deviceRegistration, string appId, string facet, bool checkOnly = false, CancellationToken?cancellationToken = null) { cancellationToken = cancellationToken ?? CancellationToken.None; if (hidDevice == null || !hidDevice.IsConnected) { throw new ArgumentException("Hid device not connected", nameof(hidDevice)); } using (var u2fHidDevice = await U2FHidDevice.OpenAsync(hidDevice)) { var startAuthentication = U2F.StartAuthentication(appId, deviceRegistration); Log.Debug("Touch token to authenticate"); var authenticateResponse = await WaitForTokenInputAsync(() => U2Fv2.AuthenticateAsync(u2fHidDevice, startAuthentication, facet, checkOnly), cancellationToken.Value).ConfigureAwait(false); U2F.FinishAuthentication(startAuthentication, authenticateResponse, deviceRegistration); Log.Debug("Authenticated"); } }