You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support for more native platforms (MacOS, Windows, Linux) #22
I Really loved this plugin, great work @LinusU. It would be great to see support for more platforms as Flutter is rising to become the leading SDK for cross-platform development.
I think support for macOS, Windows, and Linux for a start would be really helpful. I would have loved to help with this one, but I have no native development experience in any of these platforms.
I saw there is already a PR #20 trying to add macOS support, would be great to see more platforms soon.
MacOS
Windows
Linux
Reacted by nightowl00001, wrench, erebion, Dis, Gabriel Rodríguez, Casey Link, David and Joshua Mayanja
Reacted by Linus Unnebäck, Marek Gocał, Elias Deuss, FantaMagier, Marco, Jonas Franz, Luis Cruz, nightowl00001, Víctor, erebion and 1 more
I've been doing some preliminary research on how to add Windows & Linux support. As far as I can tell, there isn't really an equivalent to an SFAuthenticationSession on these platforms, but I think that we could provide something similar.
There is already #74 open for Linux support, but I believe that it takes the wrong approach since it shows its own WebView instead of integrating with the user's browser. This means that the user won't be logged in to the services, which I believe the point of this package in. (I think that the other approach is better suited for the flutter_webview package)
My idea is roughly this, which has to be done independently for Windows & Linux. (and potentially for macOS as well if the users default browser isn't Safari)
Register the app (or probably, a small shim that sends the result to the app) as the protocol handler for callbackScheme
Detect the default browser
Launch the browser with appropriate flags to show the authentication window
Wait for the callback from the browser
I think that a good approach for developing this would be:
Callback proof of concept:
Create a small binary that writes it arguments into file
Manually register this binary as the protocol handler for any protocol
Manually click a link to this protocol in Chrome/Firefox/Edge
Verify that the full url was written to file
Create a Flutter app and use it instead of the small binary
See if there is a way to get the link via an event, or if it launches a new instance of the Flutter app
Popup proof of concept:
Read the documentation on flags for Chrome/Firefox/Edge
Figure out how to launch a new window, preferably without chrome, to a specific url
Figure out how/if we can close this window programmatically
Try this out together with callback proof of concept
@LinusU For Windows and Linux I am using a different approach:
i. Start a HttpServer that listens on localhost
ii. Launch url with url_launcher
iii. Fetch redirect url and serve some HTML content like: Authenticated! You can close this tab.
Downside of this approach is that there will a useless tab left open for the user. This behaviour can also be seen on other applications (IntelliJ / Github Login).
The server returns http://localhost:3000/myapp on .authenticate() as URL but without any access token, that's the issue.
If I pass the URL from the browser to getSessionFromUrl everything works.
Is something with my scheme wrong?
I get this in the browser URL: http://localhost:3000/cryptowulf#access_token=<token> and refresh token and all other data.
_server!.listen((req) request doesnt contain the query parameters.
@SergejSachs Yes, you are right you have to use localhost as windows doesn't support custom URI schemes. I would advise checking your browsers network devtools to see what addresses are actually being called.
You should also probably use a more obscure port. The authentication will fail if something else is using that port on Windows so best practice is to use something random in the 5 digit range.
I tried it with other ports as well. The page calls access granted but the returned URL contains only the baseurl.
Im not sure if supabasees "Additional Redirect URLs" comes in place here and does not allow it.
The URL scheme is probably better, but in the meantime if that's too hard to implement, it's best to first have something than nothing, and a localhost URL works fine.
Activity
LinusU commentedon Dec 11, 2021
I've been doing some preliminary research on how to add Windows & Linux support. As far as I can tell, there isn't really an equivalent to an SFAuthenticationSession on these platforms, but I think that we could provide something similar.
There is already #74 open for Linux support, but I believe that it takes the wrong approach since it shows its own WebView instead of integrating with the user's browser. This means that the user won't be logged in to the services, which I believe the point of this package in. (I think that the other approach is better suited for the flutter_webview package)
My idea is roughly this, which has to be done independently for Windows & Linux. (and potentially for macOS as well if the users default browser isn't Safari)
callbackSchemeI think that a good approach for developing this would be:
masewo commentedon Dec 12, 2021
@LinusU For Windows and Linux I am using a different approach:
i. Start a HttpServer that listens on localhost
ii. Launch url with url_launcher
iii. Fetch redirect url and serve some HTML content like: Authenticated! You can close this tab.
Downside of this approach is that there will a useless tab left open for the user. This behaviour can also be seen on other applications (IntelliJ / Github Login).
Jon-Salmon commentedon Jan 14, 2022
I have produced a Windows implementation (https://github.com/Jon-Salmon/flutter_web_auth/tree/windows-implementation) but creating a PR is currently blocked by #98
If anybody wants to use this in the meantime, this is what you would need:
Sesa1988 commentedon Jan 26, 2022
Im waiting for the merge, this would be great.
Im getting an error if I try to integreate your current dependencies.
Could not find a file named "flutter_web_auth_window/pubspec.yaml" in https://github.com/Jon-Salmon/flutter_web_auth.git
Jon-Salmon commentedon Jan 26, 2022
@SergejSachs Typo in my comment, try adding an s
Sesa1988 commentedon Jan 26, 2022
Its working but I'm missing how to setup, its different from the current flow.
Sesa1988 commentedon Jan 26, 2022
I changed it to this but it does not get a valid session back:
The server returns http://localhost:3000/myapp on .authenticate() as URL but without any access token, that's the issue.
If I pass the URL from the browser to getSessionFromUrl everything works.
Is something with my scheme wrong?
I get this in the browser URL:
http://localhost:3000/cryptowulf#access_token=<token>and refresh token and all other data._server!.listen((req)request doesnt contain the query parameters.Jon-Salmon commentedon Jan 27, 2022
@SergejSachs Yes, you are right you have to use localhost as windows doesn't support custom URI schemes. I would advise checking your browsers network devtools to see what addresses are actually being called.
You should also probably use a more obscure port. The authentication will fail if something else is using that port on Windows so best practice is to use something random in the 5 digit range.
Sesa1988 commentedon Jan 31, 2022
@Jon-Salmon
I tried it with other ports as well. The page calls access granted but the returned URL contains only the baseurl.
Im not sure if supabasees "Additional Redirect URLs" comes in place here and does not allow it.
Sesa1988 commentedon May 8, 2022
Something new on this?
gabrc52 commentedon Jan 11, 2023
The URL scheme is probably better, but in the meantime if that's too hard to implement, it's best to first have something than nothing, and a localhost URL works fine.
Fix windows callback verification LinusU#22 (LinusU#23)