I have a Windows application written by Flutter. I use Auth0 to handle the login/logout stuff. Unlike the macOS application, Windows app can not redirect directly from the browser, so I created a local server in my application to handle the auth0 callback. It works fine in the debug mode. However, it doesn’t work when I build in the release version by the command flutter build windows --release
.
After I entered the account and the password, the browser blocked the redirection like the image below.
I am guessing it’s the cookies security issue. It’s a really weird problem that it works fine in the debug mode but does not work in the release version.
Below is the part of my code:
login() async {
final url = Uri.https(auth0Uri, '/authorize', {
'client_id': clientId,
'audience': audience,
'response_type': 'code',
'redirect_uri': redirectUri,
});
launchUrl(url);
await HttpServer.bind('localhost', 39456);
await for (var request in localServer!) {
handleRequest(request);
}
}
handleRequest(HttpRequest request) {
Uri uri = request.uri;
// Get queryParameters from uri
Map<String, String> queryParams = uri.queryParameters;
// Get code
String? code = queryParams['code'];
debugPrint('code: $code');
request.response.write("OK");
request.response.close();
}