微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决使用第三方 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 举报,一经查实,本站将立刻删除。