0

My VB.Net Windows form desktop application needs to complete an OAuth2 authorization to access online data from Intuit (QuickBooks Online). I am able to successfully (1) obtain the URL of the authorization web page, (2) redirect the user to that page, (3) receive the authorization code in the HTTP request from the URL redirect using HPPTListener when the URL is "localhost" and finally (4) retrieve the access token.

However, to use this app in production, the redirect URL cannot be "localhost" and must be https, not http. When I set the HTTPListener to monitor an https URL (e.g. https://www.stinsonsolutions.com, my web site), it does not receive any HTTP request like it does when set to monitor "localhost".

I saw one post suggesting opening a certain port in my Firewall, But since this app will be deployed to other users, that solution would not work. Is it not possible to listen to an https URL outside my app with HTTPListener, or am I missing a step? If it is not possible with HTTPListener, what can I use in my desktop application to receive the HTTP request sent to a https redirect URL?

Thanks.

  • 1
    Various other answers seem suggest to use a webbrowser control in the destop app and intercept when redirecting to a dummy site. For example: https://stackoverflow.com/questions/3744336/oauth-for-desktop-apps – mortb Mar 22 '19 at 13:23
  • and https://www.google.com/search?rlz=1C1GCEB_enSE841SE841&ei=4eGUXLPxEunamwW3sIrYBg&q=oauth+on+windows+desktop+application&oq=oauth+on+windows+desktop+application&gs_l=psy-ab.3..35i39.41344.41344..41417...0.0..0.65.65.1......0....1..gws-wiz.......0i71.0T9147_11eg – mortb Mar 22 '19 at 13:25
  • When I use the authorization web page URL in a web browser control (WebBrowser1.Navigate([AuthorizationURL]), I get a script error "An error has occurred in the script on this page, Line: 0, Char: 0, Error: Script error, Code: 0, URL: https://accounts.intuit.com/IUS-Plugins/v2/scripts/en_us/ius-core.js so the authorization page does not load properly. This did not happen when I was loading the authorization page with System.Diagnostics.Process.Start([AuthorizationURL]). – Larry Stinson Mar 25 '19 at 16:25
  • The issue seems to be that the WebBrowser control defaults to IE7 mode, which was relevant a decade ago. Seems that you can set the behavior of the WebBrowser control in the registry. It is also possible to insert a `` tag in the html `` tag if you can alter the html. https://weblog.west-wind.com/posts/2011/may/21/web-browser-control-specifying-the-ie-version. I would try to insert the `meta` tag in the head if possible, since altering the registry seems like a more complex solution which may have side effects. – mortb Mar 27 '19 at 07:58
  • It could also be possible to replace the WebBrowser control with another that does not use IE https://stackoverflow.com/questions/790542/replacing-net-webbrowser-control-with-a-better-browser-like-chrome – mortb Mar 27 '19 at 07:59
  • 1
    mortb, you hit the nail on the head. The WebBrowser control was emulating an older version of IE (even though IE 11 is installed on my PC). I added a key to the registry as explained in https://weblog.west-wind.com/posts/2011/may/21/web-browser-control-specifying-the-ie-version and now it works perfectly. Thanks a million! – Larry Stinson Mar 28 '19 at 13:28
  • Glad to be of help. Hope the solution works out for you – mortb Mar 28 '19 at 21:21

0 Answers0