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 plugins (FlutterFire) support #353

Open
3 of 10 tasks
swift-kim opened this issue Mar 30, 2022 · 24 comments
Open
3 of 10 tasks

Firebase plugins (FlutterFire) support #353

swift-kim opened this issue Mar 30, 2022 · 24 comments
Assignees
Labels
plugins Topics related to Tizen plugins

Comments

@swift-kim
Copy link
Member

swift-kim commented Mar 30, 2022

The FlutterFire Dart SDK is under active development and we may be able to use it in Tizen apps in the near future.

GitHub repo: https://github.com/invertase/flutterfire_desktop

Please check the current status of the packages or even contribute to the project if anyone is interested.

The following libraries are not supported by flutterfire_desktop. They might be implemented using the Firebase C++ SDK instead.

  • firebase_analytics
  • cloud_firestore
  • cloud_functions
  • firebase_messaging
  • firebase_storage (work in progress by flutterfire_desktop)
  • firebase_database
  • firebase_remote_config (work in progress by flutterfire_desktop)
@swift-kim swift-kim added the plugins Topics related to Tizen plugins label Mar 30, 2022
@wiertel wiertel self-assigned this Mar 30, 2022
@swift-kim swift-kim changed the title Add Firebase plugins (FlutterFire) support Firebase plugins (FlutterFire) support Apr 4, 2022
@HakkyuKim
Copy link
Contributor

@wiertel
Hi, are you still working on this? I'm thinking of having a look.

@JRazek
Copy link

JRazek commented Jun 14, 2022

@HakkyuKim
Im currently assigned to this task.

native webview does not cooperate with google oauth - flutter-tizen/plugins#390
I'm during testing whether google oauth cooperate with an ewk version of webview - flutter-tizen/plugins#400

@pkosko pkosko assigned JRazek and unassigned wiertel Jun 23, 2022
@JRazek
Copy link

JRazek commented Jun 24, 2022

I successfully logged in to google oauth with ewk_webview_flutter.

Now Ill look into how to extract the token from webview.

@JRazek
Copy link

JRazek commented Jul 5, 2022

Current state is the following:

Logging into Firebase seems to work. I added it ad-hoc in the example app. Now I'll be working on merging it into the plugin itself.

Old version of the flutter_desktop_webview_auth required an explicit call to a webview from an example app. Current version seems to have moved the webview logic to the lower layer and the user is not required to call it by themselves anymore.
It is going to help in switching to ewk_webview on Tizen.

I'll merge the upstream to the current repo containing my work and add the logic checking if the platform is Tizen. If that's the case the plugin is going to run the ewk_weview instead of flutter_desktop_webview_auth.

EDIT:
My bad, actually the current version of firebase auth desktop still requires an explicit call to webview.
The webview only returns an AuthResult object. I am currently working on implementation of flutter_desktop_webview_auth plugin that would have similar behavior to the original plugin.

@JRazek
Copy link

JRazek commented Aug 1, 2022

google_sign_in_tizen introduces an interface to obtain an OAuth token from Google API.

As the docs state, it is required to use a private key for the sake of authentication.
This forces app developer to share their apps with private keys or obfuscate their code.
Also google_sign_in on tizen platform uses a simplified flow, which requires more interaction from user.

I am currently working on implementing a tizen version of desktop_webview_auth for the firebase auth with implicit flow which does not require sharing a private key and simplifies user interaction.

Should I rather use google_sign_in or stick to the current approach?
What do you think @bwikbs @HakkyuKim @swift-kim

@bwikbs
Copy link
Member

bwikbs commented Aug 1, 2022

@JRazek
I understand your concerns (Plz, forget my previous suggestion).
IMO, There is no need to try to use google_sign_in_tizen unless you have major problems with your current task.
I think we can discuss it again later if necessary.

@swift-kim
Copy link
Member Author

@JRazek I personally prefer google_sign_in_tizen's way in terms of the user interface. If you use a webview for authentication, the user has to enter their account name and password using buttons on a remote control and that's fairly painful.

The only concern for me if we decide to use "OAuth 2.0 for TV and Limited-Input Devices" is its limited API scopes. So I think we can support both ways so that developers can choose the best option for their apps.

@JRazek
Copy link

JRazek commented Aug 22, 2022

At this moment I have a draft of a webview_auth_tizen plugin.
It is an equivalent of a flutter_desktop_webview_auth plugin.

I've decided to write a separate plugin instead of porting it because it is much simpler approach. It required no native implementation, just usage of an existing webview plugin.

Please let me know if you agree on that approach.

@swift-kim
Copy link
Member Author

swift-kim commented Aug 23, 2022

@JRazek That looks like only a partial solution for your final goal (which is to implement firebase_auth for Tizen). You need to also consider how the user (an app developer) can use your package to implement "Firebase Auth" in their app.

As you can see in the firebase_auth_desktop example, an app should depend on firebase_auth_desktop and desktop_webview_auth to implement Firebase Auth for desktop platforms. If a developer wants to add Tizen support on top of it, they will have to add tizen_webview_auth (I think this naming is better than webview_auth_tizen) as an extra dependency. The API should also look similar to desktop_webview_auth's so that the developer can write cross-platform code easily. For example,

// desktop_webview_auth
final result = await DesktopWebviewAuth.signIn(GoogleSignInArgs(...));

// tizen_webview_auth
final result = await TizenWebviewAuth.signInGoogle(...);

You can even add Tizen support to the desktop_webview_auth package by implementing its implicit method channel (in this case the Tizen package name would be desktop_webview_auth_tizen). What you have to do is to simply implement the channel in a Dart class, and you don't need to write any extra native code or add additional complexity to your code.

@swift-kim
Copy link
Member Author

The final app side code will look like this:

// If using google_sign_in:
GoogleSignIn googleSignIn = GoogleSignIn(scopes: <String>['email', 'profile']);
GoogleSignInTizen.setCredentials(
  clientId: ..,
  clientSecret: ..,
);
GoogleSignInAccount googleUser = await googleSignIn.signIn();
GoogleSignInAuthentication result = await googleUser.authentication;

// Alternatively, if using tizen_webview_auth:
AuthResult result = await TizenWebviewAuth.signInGoogle(
  clientId: ..,
  redirectUri: ..,
  scope: 'https://www.googleapis.com/auth/userinfo.email',
));

// Common to all:
OAuthCredential credential = GoogleAuthProvider.credential(
  accessToken: result.accessToken,
  idToken: result.idToken,
);
UserCredential userCredential = await FirebaseAuth.instance.signInWithCredential(credential);

A developer can choose which method to use to sign in. google_sign_in would be the best option if signing in to Google. Otherwise, tizen_webview_auth would be the only available option (as long as it supports Apple, Facebook, ...).

@JRazek
Copy link

JRazek commented Aug 23, 2022

I would call it the part of the solution rather than the partial solution.

The reason for making the webview_auth_tizen API as a widget is because in original implementation they do not pass the context.
They directly call the static function for logging
https://github.com/invertase/flutter_desktop_webview_auth/blob/7082cd06564515d7e8add0aa95e51cf90204bc53/example/lib/main.dart#L37 which calls native side and does not care about flutter at all.

There are a few solutions, that I see:

  • Do it as a free function as in the upper example, but pass a BuildContext as well,
  • Initialize a plugin with proper data,
  • Just use the plugin as it is now.

Please tell me which one will suit you best or suggest how would you do it in other way.

@swift-kim
Copy link
Member Author

@JRazek The first option makes most sense to me but it's up to your choice. Obviously the third one will require more user code than the others so you will need to provide a "complete" guide on how to use the widget. You also need to clarify how the sign-in screen should be displayed to the end user (e.g. by using showDialog or Navigator.push) and how the app should receive the result when the dialog or page is closed.

@HakkyuKim
Copy link
Contributor

Most firebase plugins are not yet supported in pure Dart: https://github.com/invertase/flutterfire_desktop.

In the meantime, we could use the Firebase C++ SDK if we can build this for Tizen architecture: https://github.com/firebase/firebase-cpp-sdk.

I'm first attempting to build for emulator, I'll share any progress worth mentioning here.

@prasanna-jeyam
Copy link

Hi @HakkyuKim,
Glad you are trying it for the Tizen arch, do you have any update on that.?

@HakkyuKim
Copy link
Contributor

Hi, @prasanna-jeyam.

I've been moved to a different project starting this year so I'm not working on this issue now. But the last time I checked, The C++ SDK didn't build for X86 (was trying to run on emulators first). I posted an issue here, I think the developer who fixed it afterwards was able to build it, but I remember it didn't work on my machine.

For wasn't able to further investigate for arm builds.

@swift-kim
Copy link
Member Author

@HakkyuKim When I checked last time (a month ago) the build itself succeeded without error. I haven't checked if the built libraries actually work on Tizen devices though.

I think we're going to work on this feature this year but still don't have detailed plans or schedules. /cc @bbrto21 @JSUYA

@bbrto21
Copy link
Contributor

bbrto21 commented Feb 3, 2023

@HakkyuKim When I checked last time (a month ago) the build itself succeeded without error. I haven't checked if the built libraries actually work on Tizen devices though.

I think we're going to work on this feature this year but still don't have detailed plans or schedules. /cc @bbrto21 @JSUYA

CC. @daeyeon @hs0225

@cbenhagen
Copy link

This issue is a showstopper for us unfortunately as our app heavily uses Firebase. Firestore and Storage in particular.

Unfortunately flutterfire_desktop is not actively developped due to a lack of funding. Maybe Samsung can help here?

The author of the firebase_dart plugin would be willing to work on this as he mentioned here for example:
appsup-dart/firebase_dart#21 (comment)

A merge with flutterfire_desktop was proposed here: appsup-dart/firebase_dart#33

A dart implementation of the most used firebase plugins would be prefered but wrapping the C++ SDK is also an option. Unfortunately it is still not recommended to be used outside of development and some features might still be stubs. If Samsung could contact the Google Firebase team on this matter and discuss a collaboration that might help a lot.

/cc @marb2000

@hs0225
Copy link

hs0225 commented Apr 10, 2023

@cbenhagen I am currently trying to support flutter firebase packages based on the firebase C++ SDK.

There is a limit to extending the flutterfire_desktop because the flutter rest api used by it provides less firebase functionality than firebase C++ SDK.

Although firebase C++ SDK also doesn't cover all the firebase features, I think it's the best way to provide more features at the moment.

But as you know, firebase C++ SDK is a beta feature. So I'm also working on validating it.

@cbenhagen
Copy link

@hs0225 thank you so much for working on this! Other platforms could also greatly benefit from this. Especially Linux and Windows.

Linking some relevant issues:
firebase/firebase-cpp-sdk#442
firebase/firebase-cpp-sdk#42

Also this discussion:
firebase/flutterfire#5557

@cbenhagen
Copy link

@hs0225 / @HakkyuKim did you see firebase/flutterfire#10496?

@cbenhagen
Copy link

@everyone please show your support for Flutter / Firebase on Linux based devices by upvoting this idea. Thanks!

@hs0225
Copy link

hs0225 commented May 24, 2023

@cbenhagen Sorry for the late reply. And thanks for your info. I will refer to it for future development.
For your information, we will start committing from firebase_core for Tizen next month.

@swift-kim
Copy link
Member Author

The flutterfire_desktop repo has been moved to the FirebaseExtended organization, and according to the recent announcement at Google I/O, there will be more Google support for this project than before. It's still not clear which way (C++ SDK or pure Dart based on REST API) they will eventually go and how much effort they will put into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugins Topics related to Tizen plugins
Projects
None yet
Development

No branches or pull requests

9 participants