flutterfire_desktop icon indicating copy to clipboard operation
flutterfire_desktop copied to clipboard

feat(firebase_remote_config): Firebase Remote Config for Dart and Desktop

Open TimWhiting opened this issue 2 years ago • 7 comments

WIP

Still some more work I can do, but ultimately blocked on installations.

TimWhiting avatar Apr 26 '22 15:04 TimWhiting

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.

TimWhiting avatar May 14 '22 03:05 TimWhiting

@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.

TimWhiting avatar May 14 '22 19:05 TimWhiting

I just realized I was using the firebaseapis package wrong. I'm going to give that approach another try.

TimWhiting avatar May 15 '22 01:05 TimWhiting

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.

pr-Mais avatar May 16 '22 09:05 pr-Mais

Hey @TimWhiting, wanna let you know that I started working on Installations and will push the PR soon.

pr-Mais avatar May 17 '22 10:05 pr-Mais

@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.

TimWhiting avatar May 19 '22 02:05 TimWhiting

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);

pr-Mais avatar May 19 '22 11:05 pr-Mais