C
C#12mo ago
Auxl

❔ HttpListener for single use request

Haven't found any useful answers online. I've got a console app where I want to open the user's main browser to an oauth login page. The callback leads back to the program at localhost. So I believe I need to run an httplistener to capture this callback. However this is the only use I would have in the program's lifetime for the httplistener. The rest of the authorization flow can be maintained through an httpclient. Is it viable or acceptable to spin up and dispose an httplistener like this? Maybe there's a better option for temporary listeners with asp? Or am I overthinking this and there's another solution?
5 Replies
Angius
Angius12mo ago
You could always just use deep linking and make the redirect URL use your custom protocol So instead of opening http://localhost?foo=bar it opens mycoolapp://myapp?foo=bar
Auxl
Auxl12mo ago
Oh that's interesting, about about to take a learning adventure ziphLooking learning adventure has told me there's plenty of resources for how to do this on windows, not so much for mac and linux Anyone got any tips for that?
jcotton42
jcotton4212mo ago
this is only really viable if the app is going to be installed I mean, why wouldn't it be acceptable to use HttpListener like that?
Auxl
Auxl12mo ago
Read that there were some issues with it not deallocating some resource even after being disposed, but naturally I can't find the link to that anymore. Figured it doesn't hurt to ask and be certain
Accord
Accord12mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.