nhost / nhost-dart

Nhost Dart & Flutter packages
https://nhost.io
MIT License
89 stars 31 forks source link

Examples showing how to use auth modules for social logins #1

Open subhendukundu opened 3 years ago

subhendukundu commented 3 years ago

I think it would be beneficial if we add different examples for all the possible logins. Clear and easy to understand.

shyndman commented 3 years ago

There is an example here for logging in via GitHub. The other providers should be similar.

Does that help?

subhendukundu commented 3 years ago

It does definitely help. But I think it's just easier for developers, easy with sample code. Sometimes they can just stuck with small things. Plus I think we should just focus on "making product as easy as possible". So they can just focus on product. We can take care of the rest. Just a thought, you don't have to take this too seriously. 🙂

PS: I can help.

shyndman commented 3 years ago

No, it's a great suggestion, and I agree the process should be easier.

One of the tricky parts about the social logins is that you need to tweak the configuration of the native app so that it recognizes a custom app URI (which calls back into the app from the browser). So it's not quite as copy-pasteable as other examples, even if all the Dart code is right in front of you. Then there's also the backend config, and having to set that up properly.

Maybe the ideal would be to add some capability to nhost_flutter_auth, or a new package (one that includes the necessary plugins)? An API where you could say nhost.auth.loginWithGitHub(), and have it return a Future that resolves just like any other login call.

It could even check your configuration (native app, and backend). Complain if it finds problems. Link you to resources that might help.

What do you think?

subhendukundu commented 3 years ago

So We can keep 2 packages. One is the core. Few devs might not want to add these but we will still add these dependencies, which is not good I think. The other package/packages, which will have all the native, and devs just plug it in and use it. Might be okay adding easy config in native if really needed to.

@elitan and I keen to make developer experiences as easy we can. Just like no-code but legos.

shyndman commented 3 years ago

@elitan and I keen to make developer experiences as easy we can. Just like no-code but legos.

Makes sense. I think we can get something like that going.

shyndman commented 3 years ago

Sorry, to be clear, that seems like a good goal, and is certainly possible. Whether to pursue is not my call.

subhendukundu commented 3 years ago

Well I had been playing around with nhost-dart for a while now. Few observations.

  1. Using app_links for the login, very smart move but I haven't able to make it work with.
  2. Docs we need to work on.

So this is what I did.

  1. I have used flutter_web_auth. Setting the callback urls to 'io.higgle.dakuapp://login-callback
    Future googleSignIn() async {
    try {
      final result = await FlutterWebAuth.authenticate(
        url: nhostGoogleLoginUrl,
        callbackUrlScheme: 'io.higgle.dakuapp://login-callback',
      );
      nhostClient.auth.completeOAuthProviderLogin(Uri.parse(result));
      return true;
    } catch (e) {
      print(e);
      return false;
    }
    }

    And this works. But what about the web support? https://daku.app has web support. Any idea?