1 year ago

#345009

test-img

Christian

Possible to create an authorized Client from FirebaseAuth to access GoogleApis in Flutter Web?

I am trying to use the SecretManagerApi in my Flutter Web app.

This is what I got so far:

import 'package:googleapis_auth/auth_io.dart';
import 'package:googleapis/secretmanager/v1.dart';
...
final client await clientViaApplicationDefaultCredentials(
    scopes: [FirestoreApi.cloudPlatformScope]);
final api = SecretManagerApi(client);
final secrets = await api.projects.secrets.versions.access(<YOUR_SECRET_NAME>);
print(secrets.payload!.data.toString());
...

but this fails because clientViaApplicationDefaultCredentials uses dart:io which is not available for Flutter Web.

Since I use Firebase to authenticate my users, I was wondering if it is possible to create such an authenticated client from the Firebase authentication data?

After all, the user is already authenticated for/with a Google product.

If this is not possible, how can I create an authenticated client for a Flutter Web App?

Here are some additional requirements:

  • I don't want to use GoogleAuth as authentication method for Firebase
  • I don't want any popups or consent screens

dart

google-api

flutter-web

google-secret-manager

0 Answers

Your Answer

Accepted video resources