Results 1 to 5 of 5

Thread: website requires authentication

  1. #1
    Join Date
    Sep 2013
    Posts
    5
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default website requires authentication

    I am developing an application that uses the ‘QWebview’ to display the websites on the internet.

    My problem is, the website which I am trying to load has a authentication popup window (HTTP BASIC AUTH) so you can enter a username and password, after the authorization, when I try to open a link in new window or tab it is keep asking me the same popup instad of loading the page directly. Here is my Webview subclass.

    Qt Code:
    1. WebView::WebView(QWidget *parent) : QWebView(parent) {
    2. page()->deleteLater();
    3. QWebPage *newWeb = new QWebPage();
    4.  
    5. NetworkAccessManager *network = new NetworkAccessManager();
    6. setPage(newWeb);
    7. setRenderHints(QPainter::SmoothPixmapTransform | QPainter::TextAntialiasing | QPainter::Antialiasing);
    8.  
    9. page()->setForwardUnsupportedContent(true);
    10. page()->setNetworkAccessManager(network);
    11. this->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
    12. this->settings()->setAttribute(QWebSettings::JavaEnabled, true);
    13. this->settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
    14. this->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
    15. this->settings()->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, true);
    16. this->settings()->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, true);
    17. this->settings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true);
    18. }
    19.  
    20. WebView *WebView::createWindow(QWebPage::WebWindowType type)
    21. {
    22. WebView *view = new WebView;
    23. return view;
    24.  
    25. }
    To copy to clipboard, switch view to plain text mode 

    If anyone can help me on this, that would be great.

    Thanks.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: website requires authentication

    The cached credentials will probably be available to all views that share the same QNetworkAccessManager. You create a new instance for each view.

  3. #3
    Join Date
    Sep 2013
    Posts
    5
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: website requires authentication

    Can you explain a bit more? as I'm just confused about this, or if you can show me some examples, that would be great.

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: website requires authentication

    Every time you create a new WebView your code creates a new NetworkAccessManager. Therefore every view, including the one your createwindow() code creates, has a distinct QNetworkAccessManager and distinct set of cached credentials and has to separately authenticate. You fix this by sharing the same NetworkAccessManager between WebViews.

  5. #5
    Join Date
    Sep 2013
    Posts
    5
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: website requires authentication

    Thanks for your help, I'm trying to implement new code right now.

    Hope I can make it work

    btw, do you have any examples?

Similar Threads

  1. Basic Authentication
    By lyhoanghai in forum Qt Programming
    Replies: 2
    Last Post: 16th May 2011, 11:00
  2. HTTPS Client Authentication (Mutual Authentication)
    By cbourne in forum Qt Programming
    Replies: 3
    Last Post: 5th December 2010, 11:51
  3. Phonon MediaSource authentication
    By serenti in forum Qt Programming
    Replies: 0
    Last Post: 11th June 2009, 23:01
  4. mutual authentication
    By abeinoe in forum Qt Programming
    Replies: 2
    Last Post: 6th April 2009, 06:22
  5. QtSoapHttpTransport and Proxy authentication
    By rmagro in forum Qt Programming
    Replies: 3
    Last Post: 16th December 2008, 12:07

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.