Implemented deep link and local server options instead web_auth #74
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR replaces web_auth library with url_launcher and app_links and
local server
options, this setup gives the user more control, also this provides a cross-platform solution (all this started because I needed desktop support).Edit: the
url_launcher
could handle an issue I saw in the issues regarding forcing a page to open in an external browser, with this PR this would be now possible.Also before I did everything you see here, I tried to implement
flutter_web_auth_2
I had ugly java kotlin compatibility issues which I wasnt able to handle, but I am not good with android configuration. The dart part was almost a drop in replacement tho.There are 2 callback strategies:
io.logto//callback
I am using GetIt for dependency injection and here is my extension method to register differen strategies (note: app id is also conditional in the config because one app is a flutter app listening to the logto scheme callback, the second is a react app listening to http callback). If this PR with modifications would go through it would be nice to allow more options for custom schemes?
Additional changes for better usability, a stream was added to the client to notify user about athentication changes, so there will be no additional state widget needed. This needs initialization for that an init() method was also added to the client. Example usage in the standard template for flutter app:
Using the stream and listen to authentication changes in an example AuthGuard widget:
Testing
I tested this by directly replacing the logto_dart_sdk with the forked and changed version locally. I run the application which I am building in an android emulator and on ubuntu as a dektop app. I tested the local server options on both devices and the scheme option on andoid only, on android the URL launcher also used a webview directly from the app.
Checklist
Nothing from these at this point, I would like to use this PR for further discussion, future options and feedback.
.changeset