Skip to content
This repository has been archived by the owner on Mar 18, 2021. It is now read-only.

Using third-parties id providers sign-in credentials #938

Open
vinnytwice opened this issue Jan 20, 2021 · 0 comments
Open

Using third-parties id providers sign-in credentials #938

vinnytwice opened this issue Jan 20, 2021 · 0 comments

Comments

@vinnytwice
Copy link

I'm trying to wrap my head around the whole Auth process as I'm building my first API/DB in Aqueduct, but I only found out on docs and other posts how to register users with email/password combination.

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

  }

In my client app I sign up/in with Google sign-in and use idToken and accessToken that the API to sign-in into Firebase ( which I'm trying to replace with this Aqueduct API ) and I want to do the same in Aqueduct.

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;
  }

So I'm looking to sign-in with the same idToken/accessToken returned from Google.
Can you guys point me in the right direction? It seems I can't find any post about this subject.

How would I create a new user this way?
Many thanks.
Cheers.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant