使用第三方 ID 提供商登录凭据在 Aqueduct 服务器中创建用户

问题描述

当我在 Aqueduct 中构建我的第一个 API/DB 时,我正在尝试围绕整个身份验证过程进行思考,但我只在文档和其他帖子中发现了如何使用电子邮件/密码组合注册用户

@Operation.post()
  Future<Response> createuser(@Bind.body() User user) async {
    if(user.username == null || user.password == null) {
      return Response.badRequest(body: {
        "error": "username and password required."});
    }

    user
      ..salt = AuthUtility.generaterandomSalt()
      ..hashedPassword = authServer.hashPassword(user.password,user.salt);
    return Response.ok( await Query(context,values: user).insert());

  }

在我的客户端应用程序中,我使用 Google 登录并使用 idToken 和 accesstoken 来登录 Firebase(我正在尝试用此 Aqueduct API 替换它),并且我想做渡槽也一样。

Future<User> signInWithGoogle() async {

    final GoogleSignInAccount googleUser = await _googleSignIn.signIn().catchError((e){
      print('Google sign in error: $e');
    });

    final GoogleSignInAuthentication googleAuth =
        await googleUser.authentication;


    final AuthCredential credential = GoogleAuthProvider.credential(
        idToken: googleAuth.idToken,accesstoken: googleAuth.accesstoken);

    await _firebaseAuth.signInWithCredential(credential);
    return _firebaseAuth.currentUser;
  }

所以我希望使用从 Google 返回的相同 idToken/accesstoken 登录。 你们能指出我正确的方向吗?我似乎找不到有关此主题的任何帖子。

我将如何以这种方式创建新用户? 非常感谢。 干杯。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)