可以从Firebaseauth创建一个授权客户端以访问Flutter Web中的Googleapis吗?

发布于 2025-01-17 18:47:13 字数 874 浏览 1 评论 0原文

我正在尝试在我的Flutter Web应用程序中使用Secretmanagerapi。

这就是我到目前为止得到的:

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

但是由于client> clientviaapplicationdefaultcredentials use dart:io,这是不可用于Flutter Web。

由于我使用firebase来验证用户,因此我想知道是否可以从Firebase身份验证数据中创建这样的经过认证的客户端?

毕竟,用户已经对/使用Google产品进行身份验证。

如果不可能,我如何为Flutter Web应用程序创建一个已验证的客户端?

以下是一些其他要求:

  • 我不想将googleauth用作firebase的身份验证方法,
  • 我不想要任何弹出式屏幕

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文