flutterfire_desktop
flutterfire_desktop copied to clipboard
feat(firebase_remote_config): Firebase Remote Config for Dart and Desktop
WIP
Still some more work I can do, but ultimately blocked on installations.
I have worked around the installations limitation for now by hardcoding an app instance id. It is working in the example app.
It turns out that the firebaseapis does not work as expected. At one point I was getting 404 errors and at one point I was getting auth errors if I remember correctly. Maybe an authenticated client is required? However, the javascript sdk does not use the same api that is generated in firebaseapis, and does not require client authentication other than the project's apiKey. Therefore, I have implemented it in that way to get an initial prototype example working.
Edit: I was looking at the wrong endpoint in the firebaseapis remote config library, and probably was not providing the right parameters in the right format.
@pr-Mais While this plugin is not 100% complete, I think it would be good to get a review at this point. The example is working, but there are things like tests and error reporting that aren't 100% complete. I don't know if you'd like to review & merge this & then do the rest in a follow-up PR. Maybe even publish a dev release before the rest is complete?
As installations would be helpful for this and other plugins. I'm willing to work on that next, I know you mentioned that you might work on it, but I don't know if you ever started, and I don't want to replicate work if you are already working on it. It should be a pretty quick one like this.
I just realized I was using the firebaseapis package wrong. I'm going to give that approach another try.
Regarding installations, if I start it will open a draft PR immediately, so if you don't see it feel free to start it, I'm currently writing additional tests for Functions.
Once you switch to firebaseapis we can merge right away.
Hey @TimWhiting, wanna let you know that I started working on Installations and will push the PR soon.
@pr-Mais I'm running into issues trying to switch this to use the firebaseapis package.
Here is a diff between the two approaches.
https://github.com/TimWhiting/flutterfire_desktop/compare/remote_config...TimWhiting:remote_config_firebaseapis?expand=1
Looking into the firebaseapis it seems as though the generated dart apis use camelCase instead of snake_case for the request body. Additionally the js-sdk (which is where I got the working approach from) puts the apiKey in the queryParameters instead of the request body. I've tried a bunch of variations of the key in the request body, and could not get it to work.
https://github.com/invertase/dart_firebase_apis/blob/c758c22835bd3dde5a3e41c209cc15abcd448b83/generated/firebaseapis/lib/firebaseremoteconfig/v1.dart#L219
The example in the firebaseapis package gets a client from application default credentials which only works in a server environment and is not meant for client side applications from what I think I've read.
Hmmm.. not sure. Have you tried using clientViaApiKey
for the client?
import 'package:googleapis_auth/auth_io.dart';
import 'package:firebaseapis/firebaseremoteconfig/v1.dart' as rc;
_client = client ?? clientViaApiKey(apiConfig.apiKey);
final rcApi = rc.FirebaseRemoteConfigApi(_client);