首页 > 解决方案 > 如何使用预设的电子邮件和密码登录 google oauth?

问题描述

我正在为客户开发一个颤振应用程序。
这涉及将文件上传到 Google 驱动器文件夹。

我已经让它与谷歌登录弹出窗口一起使用,但他们想要它,以便使用的帐户与设备帐户分开。

这可能吗?

我不认为服务帐户是正确的,因为他们仍然希望在应用程序设置中设置电子邮件和密码,据我所知,服务帐户需要直接在 API 控制台中创建和链接。

编辑:这是我当前使用 Google 登录插件登录的代码;

 static final GoogleSignIn _googleSignIn = GoogleSignIn(
     scopes: [
       g.DriveApi.DriveScope,
       g.DriveApi.DriveMetadataReadonlyScope
     ]
   );
 static dynamic token;
 ...

static login() async{
    try {
      final GoogleSignInAccount googleUser = await _googleSignIn.signIn();
      final GoogleSignInAuthentication googleAuth = await googleUser
      .authentication;
      print("signed in " + googleAuth.accessToken);
      token = googleAuth.accessToken;
      _authHeaders = await _googleSignIn.currentUser.authHeaders;
    }catch(exception){
      //maybe offline
      print("login error: "+exception.toString());
    }
  }

那么是否可以使用电子邮件和密码而不是这种方法(显示帐户选择弹出窗口)?

标签: fluttergoogle-apigoogle-drive-apigoogle-oauthgoogle-authentication

解决方案


推荐阅读