Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Firebase Auth] setAppVerificationDisabledForTesting for Android #5205

Closed
yamauchieduardo opened this issue Mar 3, 2021 · 1 comment · Fixed by #6367
Closed

[Firebase Auth] setAppVerificationDisabledForTesting for Android #5205

yamauchieduardo opened this issue Mar 3, 2021 · 1 comment · Fixed by #6367
Labels
plugin: auth type: missing-feature A feature that is supported on the underlying Firebase SDK but has not been exposed to Dart API.

Comments

@yamauchieduardo
Copy link

yamauchieduardo commented Mar 3, 2021

When the user log-in using Phone Verification (using phones numbers configured in the Firebase Console), the reCAPTCHA process starts.

In the Flutter Fire Documentation the method setSetting could enable appVerificationDisabledForTesting feature just for iOS and Web.

This setting only applies to iOS and web platforms. When set to true, this property disables app verification for the purpose of testing phone authentication. For this property to take effect, it needs to be set before handling a reCAPTCHA app verifier. When this is disabled, a mock reCAPTCHA is rendered instead. This is useful for manual testing during development or for automated integration tests.

https://pub.dev/documentation/firebase_auth/latest/firebase_auth/FirebaseAuth/setSettings.html

This method could be used with android too. Reading the Kottlin SDK documentation, we have:

Disables application verification flows for Phone Authentication and Phone Multi-Factor flows. Intended for use with the phone numbers configured in the Firebase Console for testing (Authentication > Sign In Method > Phone), or with the Firebase Auth emulator.

Once this has been called, every call to PhoneAuthProvider#verifyPhoneNumber() will skip the SafetyNet and reCAPTCHA verification flows.

https://firebase.google.com/docs/reference/kotlin/com/google/firebase/auth/FirebaseAuthSettings.html#setappverificationdisabledfortesting

This feature is very necessary, because now I can't run integration tests using android emulators. The reCAPTCHA always blocks the integration test process.

@yamauchieduardo yamauchieduardo added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Mar 3, 2021
@markusaksli-nc markusaksli-nc added plugin: auth type: missing-feature A feature that is supported on the underlying Firebase SDK but has not been exposed to Dart API. and removed Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Mar 4, 2021
@hab25
Copy link

hab25 commented Mar 9, 2021

There is a partial workaround for this: using the firebase emulators, as in that case the reCAPTCHA flow is not performed (see https://firebase.google.com/docs/emulator-suite/connect_auth#emulated_phonesms_authentication).

For convenience here's a snippet of code for this. Includes firestore emulator as well:

import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:cloud_firestore/cloud_firestore.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  if (kDebugMode) {
    final ipAddress = defaultTargetPlatform == TargetPlatform.android
        ? '10.0.2.2'
        : 'localhost';
    FirebaseFirestore.instance.settings = Settings(host: '$ipAddress:8080', sslEnabled: false);
    await FirebaseAuth.instance.useEmulator('http://$ipAddress:9099');
  }
  runApp(/*...*/)
}

@firebase firebase locked and limited conversation to collaborators Jul 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
plugin: auth type: missing-feature A feature that is supported on the underlying Firebase SDK but has not been exposed to Dart API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants