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

oauth_providers_example.dart: example needs to be updated #93

Open
diegonc opened this issue Nov 28, 2022 · 8 comments
Open

oauth_providers_example.dart: example needs to be updated #93

diegonc opened this issue Nov 28, 2022 · 8 comments
Assignees
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@diegonc
Copy link

diegonc commented Nov 28, 2022

The example's comments give wrong instructions regarding the configuration of NHost's OAuth callbacks:

At line 10 it reads:

/// Success redirect URL: `nhost-example://oauth.login.success`.
/// Failure redirect URL: `nhost-example://oauth.login.failure`.

wheareas only one callback URL can be set on GitHub settings and no URL can be set on NHost's GitHub provider configuration.

Also at line 23, the sign in URL is wrong. It should look like:

/// Fill in this value with the backend URL found on your Nhost project page.
const nhostGithubSignInUrl = '$nhostUrl/v1/auth/signin/provider/github';
@diegonc
Copy link
Author

diegonc commented Nov 29, 2022

There also seems to be a mismatch between the expected query parameter name (refresh_token) and the actual parameter name used by NHost callback (refreshToken)

image

EDIT: here is a workaround for now

if (uri.queryParameters.containsKey('refreshToken')) {
  Map<String, String> params = {};
  params.addAll(uri.queryParameters);
  params['refresh_token'] = uri.queryParameters['refreshToken']!;
  client.auth
    .completeOAuthProviderSignIn(uri.replace(queryParameters: params));
} else {
  client.auth.completeOAuthProviderSignIn(uri);
}

@mhadaily mhadaily self-assigned this Dec 4, 2022
@mhadaily mhadaily added bug Something isn't working documentation Improvements or additions to documentation labels Dec 4, 2022
@mhadaily
Copy link
Contributor

Hi,
I have updated all examples ready on this PR #95

We are activity working to improve the SDK. stay tuned.

@diegonc
Copy link
Author

diegonc commented Dec 29, 2022

Hi, thank you very much for your work!

Will this improvements include the migration from the old backend URL discussed in the link below?

nhost/nhost#1319

@mhadaily
Copy link
Contributor

Yes, I am working on it. I think we will make it in the next major release two.

@mhadaily
Copy link
Contributor

mhadaily commented Jan 11, 2023

@diegonc Check this out nhost_sdk: ^4.0.0-dev.8 or this link for supporting subdomain and region.

@totzk9
Copy link
Contributor

totzk9 commented Aug 24, 2023

Unfortunately, using launchUrl with Facebook would block me from authenticating because of Embedded browser security check from Facebook.

Found a workaround to authenticate with OAuth in Flutter though.

  1. Use this package https://pub.dev/packages/oauth_webauth specifically the BaseWebView widget
  2. add initialUrl with '${createNhostServiceEndpoint(subdomain: YOUR_SUBDOMAIN, region: YOUR_REGION, service: 'auth')}/signin/provider/facebook'
  3. add redirectUrls with your callback URL (https://xxxxxx.auth.YOUR_REGION.nhost.run/v1/signin/provider/facebook/callback)

After successful auth, should return with the callback?code=

@spakanati
Copy link
Contributor

spakanati commented Sep 29, 2023

The example now has updated URLs but still doesn't work because it refers to success/failure callback settings, which do not seem to be supported. Is there an updated suggestion for how to implement?

@dbarrosop
Copy link
Contributor

because it refers to success/failure callback settings

that part is incorrect, there is no success/failure URLs in hasura-auth, instead, if there is an error, the callback url will include an error query arg describing the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

5 participants