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 Authentication] Get ERROR_OPERATION_NOT_ALLOWED instead of ERROR_ADMIN_RESTRICTED_OPERATION when anonymous authentication disabled #2935

Closed
lukaszciastko opened this issue Jul 11, 2020 · 1 comment
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested. plugin: auth resolution: needs-repro This issue could not be reproduced or needs an up to date reproduction on latest FlutterFire plugin. type: enhancement New feature or request

Comments

@lukaszciastko
Copy link

lukaszciastko commented Jul 11, 2020

When I try to call FirebaseAuth.instance.signInAnonymously() with anonymous authentication disabled, I get the following error:

_Unhandled Exception: PlatformException(ERROR_ADMIN_RESTRICTED_OPERATION, This operation is restricted to administrators only., null)_

Moreover error stack trace is printed even if I try-catch the call:

E/flutter (25895): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: PlatformException(ERROR_ADMIN_RESTRICTED_OPERATION, This operation is restricted to administrators only., null)
E/flutter (25895): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
E/flutter (25895): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:159:18)
E/flutter (25895): <asynchronous suspension>
E/flutter (25895): #2      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:332:12)
E/flutter (25895): #3      MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:359:48)
E/flutter (25895): #4      MethodChannelFirebaseAuth.signInAnonymously (package:firebase_auth_platform_interface/src/method_channel_firebase_auth.dart:52:10)
E/flutter (25895): #5      FirebaseAuth.signInAnonymously (package:firebase_auth/src/firebase_auth.dart:42:45)
E/flutter (25895): #6      _AppViewState.build.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:blitaporder/main.dart:75:47)
E/flutter (25895): #7      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:953:19)
E/flutter (25895): #8      _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:1059:38)
E/flutter (25895): #9      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter (25895): #10     TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:522:11)
E/flutter (25895): #11     BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:282:5)
E/flutter (25895): #12     BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:217:7)
E/flutter (25895): #13     PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:475:9)
E/flutter (25895): #14     PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:76:12)
E/flutter (25895): #15     PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:122:9)
E/flutter (25895): #16     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)
E/flutter (25895): #17     PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:120:18)
E/flutter (25895): #18     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:106:7)
E/flutter (25895): #19     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:218:19)
E/flutter (25895): #20     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
E/flutter (25895): #21     GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
E/flutter (25895): #22     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
E/flutter (25895): #23     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
E/flutter (25895): #24     _rootRunUnary (dart:async/zone.dart:1206:13)
E/flutter (25895): #25     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter (25895): #26     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
E/flutter (25895): #27     _invoke1 (dart:ui/hooks.dart:281:10)
E/flutter (25895): #28     _dispatchPointerDataPacket (dart:ui/hooks.dart:190:5)

To Reproduce

Implement the following code, e.g. in an onPressed callback of a FlatButton:

try {
  FirebaseAuth.instance.signInAnonymously();
} catch (e) {
  print('Error: $e');
}

Expected behavior

According to the documentation, the error I should be getting in this case is: ERROR_OPERATION_NOT_ALLOWED.

No stack trace should be printed if the error is in a try-catch statement.

Additional context

I'm using:
firebase_auth: ^0.16.1

Flutter doctor

[✓] Flutter (Channel beta, 1.19.0-4.3.pre, on Mac OS X 10.15.5 19F101, locale en-GB)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.0)
[!] Android Studio
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] VS Code (version 1.47.0)
[✓] Connected device (3 available)

@TahaTesser TahaTesser changed the title [Firebase Authentication] ERROR_ADMIN_RESTRICTED_OPERATION error when anonymous authentication not enabled [Firebase Authentication] Get ERROR_OPERATION_NOT_ALLOWED instead of ERROR_ADMIN_RESTRICTED_OPERATION when anonymous authentication disabled Jul 14, 2020
@TahaTesser TahaTesser added plugin: auth type: enhancement New feature or request labels Jul 14, 2020
@Salakar Salakar added blocked: customer-response Waiting for customer response, e.g. more information was requested. resolution: needs-repro This issue could not be reproduced or needs an up to date reproduction on latest FlutterFire plugin. labels Aug 25, 2020
@Ehesp
Copy link
Member

Ehesp commented Aug 25, 2020

@lukaszciastko Please could you upgrade to the latest version of auth? This should now be fixed. Will close. Please let me know if you have any more issues.

@Ehesp Ehesp closed this as completed Aug 25, 2020
@firebase firebase locked and limited conversation to collaborators Sep 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested. plugin: auth resolution: needs-repro This issue could not be reproduced or needs an up to date reproduction on latest FlutterFire plugin. type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants