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] Cannot use new Firebase Auth Emulator #3980

Closed
radvansky-tomas opened this issue Oct 28, 2020 · 53 comments
Closed

🐛 [firebase_auth] Cannot use new Firebase Auth Emulator #3980

radvansky-tomas opened this issue Oct 28, 2020 · 53 comments
Labels
impact: crowd Affects many people, though not necessarily a specific customer with an assigned label. (P2) plugin: auth type: enhancement New feature or request

Comments

@radvansky-tomas
Copy link

I think before I've added it here #3969

But basically plugin does not export useEmulator() method to use new Firebase Auth Emulator Suite

@radvansky-tomas radvansky-tomas added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Oct 28, 2020
@markusaksli-nc markusaksli-nc added plugin: auth type: enhancement New feature or request and removed Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Oct 29, 2020
@radvansky-tomas
Copy link
Author

I've checked code briefly, and its using outdated native SDKs to support it. I am expecting that there is upcoming version bump, so can revisit later ;)

@Ehesp
Copy link
Member

Ehesp commented Nov 3, 2020

This requires a SDK version updated, however some of the other plugins will break if we upgrade the BoM versions. There are potential workarounds we're looking into and have discussed.

@celesteking
Copy link

celesteking commented Nov 17, 2020

Discussed with whom and where? Is this a feature that's supported? If not, it makes worth noting in docs that Firebase Auth Emulator isn't supported in flutter yet. Thanks.

update: Also, what is a "new emulator"? Have you created a new version of firebase emulator?

@markusaksli-nc markusaksli-nc added the impact: crowd Affects many people, though not necessarily a specific customer with an assigned label. (P2) label Nov 18, 2020
@mikehardy
Copy link
Contributor

mikehardy commented Nov 18, 2020

@celesteking There is one emulator suite, it contains a new auth emulator. The auth emulator requires minimum firebase-ios-sdk version 7.0.0 (7.1.0 is current) and firebase-android-sdk 26.0.0 (26.1.0 is current as of now). You are likely aware Invertase is currently working hard on FlutterFire, with a crew of between 4-6 at any given time, and the discussions are internal because there is a mountain of work to do - prioritizing it and scheduling it is the same as in any other work project.

Looks to me like the docs are open source, you could PR a note to them at any time? https://github.com/FirebaseExtended/flutterfire/tree/master/docs/auth

I'm going to be doing a quick sizing exercise on fastest path towards an upgrade to the underlying SDKs starting shortly now that I've finished doing the same for react-native-firebase (invertase/react-native-firebase#4471) and if it's possible quickly then I'll add auth emulator support similar to the same I just released over there (invertase/react-native-firebase#4552)

Hopefully it's quick work but I'm not sure of the size of forward port so it's hard to say.

We'll be sure to keep this issue updated though!

@yulkin2002
Copy link

yulkin2002 commented Dec 4, 2020

any news on auth emulator support?
also, can anyone suggest a good workaround without having to disable all the auth code in my app?

@mikehardy
Copy link
Contributor

mikehardy commented Dec 4, 2020

Yes, it "works"! :-), #4263 (you can follow along there) but it's a breaking change to forward port, which is something that needs to be done at a measured pace with great documentation and planning

Plus the 2 PRs that take the repo through the breaking change and to the auth emulator support are still very rough.

But it is open source, anyone can use my branch. There are only a few key commits that do the forward port (ML items, RemoteConfig, and one Messaging item if I recall correctly) so it's not that large a change really.

@braamgenis
Copy link

@yulkin2002

also, can anyone suggest a good workaround without having to disable all the auth code in my app?

Using remote auth with local firestore/cloud functions emulators works, if that's what you mean?

@mikehardy
Copy link
Contributor

Well, not sure on the depth and breadth of the tests in question, but at least from a maintainer perspective where we are frequently doing full CI runs against the same firebase project, we run into Auth API call rate limiting that flakes our CI frequently. Plus it's not nearly as fast - so I do see the need and for some projects it is a fairly serious one, but until the work is done, having an "isCI()" type flag and/or only running specific auth tests manually against the real APIs is the way to go.

Another consideration is that perhaps through no fault of the developer they do not have a test project with separate data to run against, and running tests against production data is not allowed.

@yulkin2002
Copy link

@braamgenis thank you! I didn't realize they would work together.

@alejandroaap
Copy link

Any news about this functionality? Why do flutter sdks lag far behind native sdks?

@mikehardy
Copy link
Contributor

@alejandroaap I don't recall any feedback from you testing my PR to bring them up to date? I'd love to hear how it worked for you. Thanks!

@jans-y
Copy link

jans-y commented Dec 15, 2020

@mikehardy Hi, I have tried it but I couldn't build the app afterwards.

Since auth emulator is supported AFAIK from Firebase iOS SDK 7.2.0 or newer, changing globally all my Firebase CocoaPods plugins to that version (I wasn't able to do it for the Auth Pod only) resulted in multiple Swift/Objective C errors when building the App for the simulator and device.

I think that Remote Config was one of those plugins that couldn't build with the new Firebase iOS SDK.

Thank you for your efforts.

@mikehardy
Copy link
Contributor

@jans-y that is unexpected, as remote-config was one of the items considered, and handled in the port ea18fd2 and I specifically added test harness powers that ensured they built and passed tests

cf1b55f#diff-cd98883b899aa4ad62ac6b5c5c3db5146fd0a5465749d4d3de63a77c525c04d3R20

cf1b55f#diff-cd98883b899aa4ad62ac6b5c5c3db5146fd0a5465749d4d3de63a77c525c04d3R43-R44

cf1b55f#diff-cd98883b899aa4ad62ac6b5c5c3db5146fd0a5465749d4d3de63a77c525c04d3R110-R111

All of which work locally for me.

I'm not saying the PR is perfect, but the problems you had are unexpected vs the specific changes I made, and I suspect something locally was cached or similar. I added a "clean:deep" target to hopefully work around that with melos run clean:deep 34902db

It is also possible that the tip of the main branch has moved on in an incompatible way since I posted the PR for consideration. I haven't attempted to run it in the last few days.

@alejandroaap
Copy link

alejandroaap commented Dec 15, 2020

@mikehardy I am trying to test your PR and I am having the following problem when running the application on an iphone.

packages / firebase_auth / firebase_auth / ios / Classes / FLTFirebaseAuthPlugin.m: 557: 9: error: not visible @interface for 'FIRAuth' declares the selector 'useEmulatorWithHost: port:' [auth useEmulatorWithHost: arguments [@ "host"] port: arguments [@ "port"]];

Any idea why it might be?

Thank you.

@mikehardy
Copy link
Contributor

Sure, for some reason the underlying firebase-ios-sdk version is not updated correctly. You must have 7.0.0 or greater, 7.3.0 is current as of this writing. Where ever you have it specified, update it to 7.3.0

@alejandroaap
Copy link

You're right, that was the problem, when will the PR be completed? Thank you

@mikehardy
Copy link
Contributor

@alejandroaap I'm not sure as I'm not in control of that in any way, but seeing users request it, and validate that it is working can only help. Make sure you're subscribed to it and have given a thumbs-up reaction to the issue itself at the top - those are a bit like votes, perhaps ask others to do so

@mikehardy
Copy link
Contributor

Also perhaps subscribe / thumbs-up the PR itself :-)

@jlubeck
Copy link

jlubeck commented Dec 16, 2020

@mikehardy Will this also work for using the firestore emulator? or only for auth? Do we need a new ticket for firestore? Couldn't find any reference to that...

@mikehardy
Copy link
Contributor

I believe that firestore and functions emulators are already working and usable. You may see examples of their usage in the code base here if you look in the .github/workflows directory as they are used for the e2e tests that run against commits and PRs here.

@alejandroaap
Copy link

Hi @jlubeck With firestore it's already possible to use the emulator. Take a look at the documentation https://firebase.flutter.dev/docs/firestore/usage

`// Import foundation for [TargetPlatform].
import 'package:flutter/foundation.dart';

// Switch host based on platform.
String host = defaultTargetPlatform == TargetPlatform.android
? '10.0.2.2:8080'
: 'localhost:8080';

// Set the host as soon as possible.
FirebaseFirestore.instance.settings =
Settings(host: host, sslEnabled: false);
`

@jlubeck
Copy link

jlubeck commented Dec 16, 2020

Yes! Thank you @mikehardy and @alejandroaap that indeed works.
Looking forward to the auth emulator support. I'll see if i can test out that PR in the meantime.

@jlubeck
Copy link

jlubeck commented Dec 16, 2020

Hey, how can I use that PR as my dependency? Should I reference the latest commit on that PR?

@jlubeck
Copy link

jlubeck commented Dec 16, 2020

The firebase_core module should have changed it yes. There are docs showing how to override it if you like as well. 7.3.0 is current

Sorry, I'm not sure I understand (english is not my main language, sorry). So you are saying that just by implementing that PR into my overrides it SHOULD have changed the Podfile to make it work?

Because if that's the case, that's not working as intended...

@jlubeck
Copy link

jlubeck commented Dec 17, 2020

@mikehardy @alejandroaap I can't seem to find those docs explaining how to override the podfile to use 7.3.0. Would you be so kind to point me to them please? Thanks!

@mikehardy
Copy link
Contributor

mikehardy commented Dec 17, 2020

Apologies, English is my first language but I am not always clear in it :-), also I have learned another language and I know how hard it can be even when things are clear, so I empathize. That said...

You should be able to override the versions - I think - by setting FirebaseSDKVersion in your Podfile, that is what the cocoapod .podspec files seem to be looking for:

https://github.com/FirebaseExtended/flutterfire/blob/985b811f9c680836fe25de35ec3dfcf860610d65/packages/cloud_firestore/cloud_firestore/ios/cloud_firestore.podspec#L6-L9

[edited to add: I do note that for some reason my firebase_core changes aren't taking effect, I am not sure why but I note it - thank you for that feedback + testing]

@jlubeck
Copy link

jlubeck commented Dec 17, 2020

Hi @mikehardy thank you for that. I added that variable in my Podfile, but i'm getting this error on pod install or pod update

Analyzing dependencies
cloud_firestore: Using user specified Firebase SDK version '7.0.0'
firebase_analytics: Using user specified Firebase SDK version '7.0.0'
firebase_auth: Using user specified Firebase SDK version '7.0.0'
firebase_core: Using user specified Firebase SDK version '7.0.0'
firebase_messaging: Using user specified Firebase SDK version '7.0.0'
firebase_storage: Using user specified Firebase SDK version '7.0.0'
[!] CocoaPods could not find compatible versions for pod "firebase_auth":
  In Podfile:
    firebase_auth (from `.symlinks/plugins/firebase_auth/ios`)

Specs satisfying the `firebase_auth (from `.symlinks/plugins/firebase_auth/ios`)` dependency were found, but they required a higher minimum deployment target.

@mikehardy
Copy link
Contributor

All ios deployment minimums are bumped to 10, corresponding changes are required in the podfile, should get past that

@jlubeck
Copy link

jlubeck commented Dec 17, 2020

Step by step... 😓

Now if I do pod update I get this

jan@Jans-MacBook-Pro ios % pod update


Update all pods
Updating local specs repositories
Analyzing dependencies
cloud_firestore: Using user specified Firebase SDK version '7.0.0'
firebase_analytics: Using user specified Firebase SDK version '7.0.0'
firebase_auth: Using user specified Firebase SDK version '7.0.0'
firebase_core: Using user specified Firebase SDK version '7.0.0'
firebase_messaging: Using user specified Firebase SDK version '7.0.0'
firebase_storage: Using user specified Firebase SDK version '7.0.0'
Downloading dependencies
Installing DKImagePickerController 4.3.2 (was 4.2.2)
Installing DKPhotoGallery 0.0.17 (was 0.0.14)
Installing Firebase 7.0.0 (was 6.33.0)
Installing FirebaseAnalytics 7.0.0 (was 6.8.3)

[!] Error installing FirebaseAnalytics
[!] /usr/bin/curl -f -L -o /var/folders/6d/7fb8q3_576358cs38040dm8h0000gn/T/d20201217-97653-1r0va28/file.tgz https://dl.google.com/firebase/ios/analytics/85d51ebb1b58f88f/FirebaseAnalytics-7.0.0.tar.gz --create-dirs --netrc-optional --retry 2 -A 'CocoaPods/1.10.0 cocoapods-downloader/1.4.0'

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (7) Failed to connect to dl.google.com port 443: Bad file descriptor

If I do pod install I get this:

jan@Jans-MacBook-Pro ios % pod install
Analyzing dependencies
cloud_firestore: Using user specified Firebase SDK version '7.0.0'
firebase_analytics: Using user specified Firebase SDK version '7.0.0'
firebase_auth: Using user specified Firebase SDK version '7.0.0'
firebase_core: Using user specified Firebase SDK version '7.0.0'
firebase_messaging: Using user specified Firebase SDK version '7.0.0'
firebase_storage: Using user specified Firebase SDK version '7.0.0'
[!] CocoaPods could not find compatible versions for pod "Firebase/Firestore":
  In snapshot (Podfile.lock):
    Firebase/Firestore (= 6.33.0, ~> 6.33.0)

  In Podfile:
    cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`) was resolved to 0.14.4, which depends on
      Firebase/Firestore (~> 7.0.0)


You have either:
 * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
 * changed the constraints of dependency `Firebase/Firestore` inside your development pod `cloud_firestore`.
   You should run `pod update Firebase/Firestore` to apply changes you've made.

@Pcol10
Copy link

Pcol10 commented Dec 17, 2020

Step by step... 😓

Now if I do pod update I get this

jan@Jans-MacBook-Pro ios % pod update


Update all pods
Updating local specs repositories
Analyzing dependencies
cloud_firestore: Using user specified Firebase SDK version '7.0.0'
firebase_analytics: Using user specified Firebase SDK version '7.0.0'
firebase_auth: Using user specified Firebase SDK version '7.0.0'
firebase_core: Using user specified Firebase SDK version '7.0.0'
firebase_messaging: Using user specified Firebase SDK version '7.0.0'
firebase_storage: Using user specified Firebase SDK version '7.0.0'
Downloading dependencies
Installing DKImagePickerController 4.3.2 (was 4.2.2)
Installing DKPhotoGallery 0.0.17 (was 0.0.14)
Installing Firebase 7.0.0 (was 6.33.0)
Installing FirebaseAnalytics 7.0.0 (was 6.8.3)

[!] Error installing FirebaseAnalytics
[!] /usr/bin/curl -f -L -o /var/folders/6d/7fb8q3_576358cs38040dm8h0000gn/T/d20201217-97653-1r0va28/file.tgz https://dl.google.com/firebase/ios/analytics/85d51ebb1b58f88f/FirebaseAnalytics-7.0.0.tar.gz --create-dirs --netrc-optional --retry 2 -A 'CocoaPods/1.10.0 cocoapods-downloader/1.4.0'

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (7) Failed to connect to dl.google.com port 443: Bad file descriptor

If I do pod install I get this:

jan@Jans-MacBook-Pro ios % pod install
Analyzing dependencies
cloud_firestore: Using user specified Firebase SDK version '7.0.0'
firebase_analytics: Using user specified Firebase SDK version '7.0.0'
firebase_auth: Using user specified Firebase SDK version '7.0.0'
firebase_core: Using user specified Firebase SDK version '7.0.0'
firebase_messaging: Using user specified Firebase SDK version '7.0.0'
firebase_storage: Using user specified Firebase SDK version '7.0.0'
[!] CocoaPods could not find compatible versions for pod "Firebase/Firestore":
  In snapshot (Podfile.lock):
    Firebase/Firestore (= 6.33.0, ~> 6.33.0)

  In Podfile:
    cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`) was resolved to 0.14.4, which depends on
      Firebase/Firestore (~> 7.0.0)


You have either:
 * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
 * changed the constraints of dependency `Firebase/Firestore` inside your development pod `cloud_firestore`.
   You should run `pod update Firebase/Firestore` to apply changes you've made.
  1. Delete Podfile.lock
  2. run pod repo update
  3. Now you Can try again your stuff

@mikehardy
Copy link
Contributor

mikehardy commented Dec 17, 2020

Indeed - those steps should work. Sorry for not having complete instructions on all this, I've been doing cocoapods just long enough that all these things are reflex for me now so I don't think to specify them (pod repo update, deleting locks, reupdating etc) but I definitely remember when I first started with cocoapods and it was all foreign and I had no idea what to do. Quite frustrating. Thanks @Pcol10 for helping!

@jlubeck
Copy link

jlubeck commented Dec 17, 2020

I'm about to give up... :(

Now I'm getting a bunch of other errors, for example:

/Users/jan/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-7.0.3/ios/Classes/FLTFirebaseMessagingPlugin.m:291:63: error: property 'appData' not found on object of type '__strong id'
      [_channel invokeMethod:@"onMessage" arguments:remoteMessage.appData];

@mikehardy
Copy link
Contributor

🤔 that is unexpected, I will not hold it against you at all if you give up, PRs are always hard to integrate and test, I think the way Flutter works makes it even harder with the unified global pub-cache, and this PR in particular is still pretty speculative. So no worries, no expectations.

I'm about to refresh the PRs against tip of main branch to make sure they are still "alive"/"fresh" and it's possible something diverged and is not working right now until that is done.

You might make sure you are using firebase-ios-sdk 7.3.0 just in case that matters.

@jlubeck
Copy link

jlubeck commented Dec 17, 2020

thank you for your constantn help @mikehardy unfortunately even after using 7.3.0, cleaning the flutter projects, the pod files, etc, I'm still getting that last error that I shared. It might be like you said a mix of things...

Unless @alejandroaap can chime in to show how he got his working (maybe he doesn't use other Firebase packages like I'm using?), I'm not sure what else to do but wait for further progress on those other tickets.

@radvansky-tomas
Copy link
Author

Any updates ? With latest updates and bumped SDKs it should be pretty straightforward to enable this, right ?

@mikehardy
Copy link
Contributor

PR #4263 contains all progress, follow that for updates.

I think it's close (as in, may be ready today? Maybe tomorrow?) but software is notoriously hard to predict yes? So could be longer.

All of the necessary pre-requisite work has been completed and merged though (that is: forward-porting across a breaking change version of the underlying firebase SDKs). That took a while.

@Tinhorn
Copy link

Tinhorn commented Jan 12, 2021

This is amazing.
Thank you for all the hard work.
This will make my workflow so much better

@LucasHenriqueAbreu
Copy link

Mine too

@mikehardy
Copy link
Contributor

@LucasHenriqueAbreu @Tinhorn head on over and test the PR then, it should be working fully now as of around 16 hours ago, there are instruction in the PR that show how to test it #4263

@deep-randhawa
Copy link

@mikehardy any updates on this?

@mikehardy
Copy link
Contributor

Did you check the PR @deep-randhawa ? It's merged. I think it's even been cherry-picked to the stable branch. There will be no further updates, this should be closed, the work is done now.

@markusaksli-nc
Copy link
Contributor

I guess I'll close this as fixed then

@sderungs99
Copy link

Shouldn't there be documentation how to use it here (https://firebase.flutter.dev/docs/auth/usage), before we close this?

@markusaksli-nc
Copy link
Contributor

@sderungs99 Do you mean something like https://firebase.flutter.dev/docs/firestore/usage#emulator-usage?

I think you can go ahead and make a separate documentation issue for this.

@sderungs99
Copy link

Yes, that's exactly what I meant :-) I'm happy to raise an issue, but before I do that, I'm still a bit confused in which exact version of firebase_auth this is available. I checked the PR that is referred above, but that didn't help. Anyone can advise?

@markusaksli-nc
Copy link
Contributor

It isn't in stable yet but it will be soon

#4263 (comment)
#4263 (comment)

@Yirmeyah-d
Copy link

@jlubeck Same here, did you find a solution ?

@Yirmeyah-d
Copy link

Nevermind i just had to update the versions of the firebase packages that where in the pubspec.yaml.
And after this, everything worked fine

@wtfiwtz
Copy link

wtfiwtz commented Mar 1, 2021

PR #5171 fixes an issue with web

@mikehardy
Copy link
Contributor

@wtfiwtz yes! Thanks for cross-linking it here. It comes along with the need to update the firebase-js-sdk dependency which has a known issue with firestore, but those are all being tracked separately. auth.useEmulator has now been successfully tested (by me at least) on iOS/Android/Web

@firebase firebase locked and limited conversation to collaborators Mar 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
impact: crowd Affects many people, though not necessarily a specific customer with an assigned label. (P2) plugin: auth type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests