Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need help with setting up social auth for flutter #349

Closed
Wizzel1 opened this issue Feb 7, 2023 · 9 comments
Closed

Need help with setting up social auth for flutter #349

Wizzel1 opened this issue Feb 7, 2023 · 9 comments
Labels
auth This issue or pull request is related to authentication enhancement New feature or request

Comments

@Wizzel1
Copy link
Contributor

Wizzel1 commented Feb 7, 2023

I am trying to setup discord authentication for my windows app but I got a bit lost with it.

I saw that it got implemented with this PR #136.
and I have completed the setup steps that are required for the https://pub.dev/packages/app_links package to run. (Altering the files in windows/runner)

What am I supposed to do now? Is there any documentation for this?

@Wizzel1 Wizzel1 added the enhancement New feature or request label Feb 7, 2023
@dshukertjr dshukertjr added the auth This issue or pull request is related to authentication label Feb 8, 2023
@dshukertjr
Copy link
Member

Once you have setup deeplinks as instructed on the app_links's page on Windows, calling signInWithOAuth should work launch the web browser, and upon completing the sign-in, it should bring you back to the app, but is it not?

await supabase.auth.signInWithOAuth(
  Provider.google,
  redirectTo: kIsWeb ? null : 'io.supabase.flutter://reset-callback/',
);

If you have the redirectTo specified and you have setup addition redirect URLs and the app is still not opening upon successfully signing in, you may consider opening an issue with app_links.

@Wizzel1
Copy link
Contributor Author

Wizzel1 commented Feb 8, 2023

I didn't see the deep-link section in the package before, I will do it step by step again to make sure I didn't miss anything.

One question though: I am not sure how this 'io.supabase.flutter://reset-callback/' is built up.
Should it look like 'io.myApp.flutter://reset-callback/' or 'io.supabase.myApp://reset-callback/'

@dshukertjr
Copy link
Member

dshukertjr commented Feb 8, 2023

@Wizzel1
The deep link section can use some improvement. If you will, please let us know if anything is hard to understand!

So the URI can actually be anything actually. It doesn't have to include supabase or reset-callback at all.

foo://callback is a valid deep link as well as io.my-domain.app://login-callback. It should look like the later, because deep links have to be unique across the installed device, so developers typically use the inverted domain that they own.

@Wizzel1
Copy link
Contributor Author

Wizzel1 commented Feb 8, 2023

@dshukertjr I see. The thing that got me confused is the following:

When setting up discord as auth provider I need to enter a "redirection link" on the discord page.
The link I entered there is the one thats shown at Authentication -> Providers -> Discord -> Redirect URL and it looks something like this: https://xyz.supabase.co/auth/v1/callback.

Isn't this supposed to be the same link as the link in

await supabase.auth.signInWithOAuth(
  Provider.google,
  redirectTo: kIsWeb ? null : 'io.supabase.flutter://reset-callback/',
);

I tried to use io.my-domain.app://login-callback but it throws an error on the discord side 'invalid redirect url'

What is the difference between this redirectTo and the link I need to paste into discord?

@dshukertjr
Copy link
Member

@Wizzel1
Thanks for the feedback. We definitely have some room of improvement in our readme explaining how to setup OAuth login.

What you enter in the redirection link within your Discord auth provider is the destination of the user after completing the sign-in on Discord. What you pass to the redirectTo on supabase.auth.signInWithOAuth() is the final destination of the user after completing all steps of OAuth login.

The flow goes like this:
supabase.auth.signInWithOAuth() -> Discord sign-in page -> https://xyz.supabase.co/auth/v1/callback -> Whatever you enter on redirectTo

So what you enter on the Discord as the redierction link and what you pass to the redirectTo parameter will be different.

@Wizzel1
Copy link
Contributor Author

Wizzel1 commented Feb 8, 2023

@dshukertjr Understood. So when I am calling the signIn method like so:

await supabase.auth.signInWithOAuth(
  Provider.google,
  redirectTo: kIsWeb ? null : 'io.supabase.flutter://reset-callback/',
);

do I still need to create this io.supabase.flutter://reset-callback/' at Authentication -> Providers -> Discord -> Redirect URL?

Or in other words: Is the parameter in

  redirectTo: kIsWeb ? null : 'io.supabase.flutter://reset-callback/',

a reference to a redirection link from Authentication -> Providers -> Discord -> Redirect URL or can one exist without the other?

@dshukertjr
Copy link
Member

@Wizzel1

do I still need to create this io.supabase.flutter://reset-callback/' at Authentication -> Providers -> Discord -> Redirect URL?

What you see in Authentication -> Providers -> Discord -> Redirect URL is not editable. That is just the value you need to copy and paste on Discord's configuration page.
Screen Shot 2023-02-08 at 22 36 57

You need to instead add your deep link to Authentication -> URL Configuration -> Redirect URLs
Screen Shot 2023-02-08 at 22 38 11

@Wizzel1
Copy link
Contributor Author

Wizzel1 commented Feb 8, 2023

@dshukertjr yes, sorry. Instead of Authentication -> Providers -> Discord -> Redirect URL I meant Authentication -> URL Configuration -> Redirect URLs

@Wizzel1
Copy link
Contributor Author

Wizzel1 commented Feb 8, 2023

@dshukertjr I will give this a try and reopen this issue if I get stuck again. Thanks for helping!

@Wizzel1 Wizzel1 closed this as completed Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth This issue or pull request is related to authentication enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants