Use random port for http server port

Android does not allow binding static ports.
This commit is contained in:
lemoer 2025-07-11 23:48:37 +02:00
parent 9607d2ca0c
commit 10a4909d5d

View File

@ -548,7 +548,10 @@ class AuthentikUserSettingsChangeDialogState extends ChangeNotifier {
final identifier = 'UwSMm8gTwBTUURSaxp5uPpuwX1OkGO4FRHeO9v3i';
final secret = null;
final redirectUrl = Uri.parse('http://localhost:30165/');
server = await HttpServer.bind("127.0.0.1", 0);
final port = server!.port;
final redirectUrl = Uri.parse('http://localhost:$port/');
var grant = oauth2.AuthorizationCodeGrant(
identifier,
@ -562,8 +565,6 @@ class AuthentikUserSettingsChangeDialogState extends ChangeNotifier {
scopes: ["profile", "email", "goauthentik.io/api", "openid"],
);
server = await HttpServer.bind("127.0.0.1", 30165);
if (!await launchUrl(
authorizationUrl,
mode: LaunchMode.externalApplication,