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

Dart oauth2 login example #503

Closed
joranmulderij opened this issue Sep 16, 2022 · 1 comment
Closed

Dart oauth2 login example #503

joranmulderij opened this issue Sep 16, 2022 · 1 comment

Comments

@joranmulderij
Copy link

Could you make it clear in the documentation how to do oauth2 login in dart. There is a JavaScript example, but it is not clear how to do this with a dart mobile or web app. It would be nice to specify if this is actually possible, and if it is there should be something in the documentation showing how to do it, preferably in a way that is understandable for people that don't actually know exactly how oauth2 works.

@ganigeorgiev
Copy link
Member

ganigeorgiev commented Sep 16, 2022

The documentation will be refactored in the near future and I'll add a Dart OAuth2 example, but that will be after #376.

Also please note that there are plans to simplify the OAuth2 flow in #55.


The Dart mobile flow is very similar to the JS example, with the main difference that instead of a regular redirect url you have to use a deep-link.

You'll need at least one screen to show the "Login with ..." buttons. Similar to the JS example, you can use client.users.listAuthMethods() to get the list of the currently allowed providers.
Note that most OAuth2 providers no longer allow webviews, so on a button click you need to open the url in the device's browser or use something like https://pub.dev/packages/flutter_web_auth that will open the url via ASWebAuthenticationSession or Chrome Custom Tabs.

The second activity/screen that you'll need would be to handle the deep-link redirect so that you can exchange the auth code for PocketBase token. This is where you call client.users.authViaOAuth2(...).

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

No branches or pull requests

2 participants