diff --git a/examples/widgets/browser/networkaccessmanager.cpp b/examples/widgets/browser/networkaccessmanager.cpp
index ae5dfe4dea5205f4d452fe1744898594d373405c..a7127ade6bac4cba22d83f5479ab7425f24c2462 100644
--- a/examples/widgets/browser/networkaccessmanager.cpp
+++ b/examples/widgets/browser/networkaccessmanager.cpp
@@ -43,8 +43,6 @@
 
 #include "browserapplication.h"
 #include "browsermainwindow.h"
-#include "ui_passworddialog.h"
-#include "ui_proxy.h"
 
 #include <QtCore/QSettings>
 
@@ -66,10 +64,6 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent)
     requestFinishedCount(0), requestFinishedFromCacheCount(0), requestFinishedPipelinedCount(0),
     requestFinishedSecureCount(0), requestFinishedDownloadBufferCount(0)
 {
-    connect(this, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
-            SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*)));
-    connect(this, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
-            SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
     connect(this, SIGNAL(finished(QNetworkReply*)),
             SLOT(requestFinished(QNetworkReply*)));
 #ifndef QT_NO_OPENSSL
@@ -140,54 +134,6 @@ void NetworkAccessManager::loadSettings()
     setProxy(proxy);
 }
 
-void NetworkAccessManager::authenticationRequired(QNetworkReply *reply, QAuthenticator *auth)
-{
-    BrowserMainWindow *mainWindow = BrowserApplication::instance()->mainWindow();
-
-    QDialog dialog(mainWindow);
-    dialog.setWindowFlags(Qt::Sheet);
-
-    Ui::PasswordDialog passwordDialog;
-    passwordDialog.setupUi(&dialog);
-
-    passwordDialog.iconLabel->setText(QString());
-    passwordDialog.iconLabel->setPixmap(mainWindow->style()->standardIcon(QStyle::SP_MessageBoxQuestion, 0, mainWindow).pixmap(32, 32));
-
-    QString introMessage = tr("<qt>Enter username and password for \"%1\" at %2</qt>");
-    introMessage = introMessage.arg(reply->url().toString().toHtmlEscaped()).arg(reply->url().toString().toHtmlEscaped());
-    passwordDialog.introLabel->setText(introMessage);
-    passwordDialog.introLabel->setWordWrap(true);
-
-    if (dialog.exec() == QDialog::Accepted) {
-        auth->setUser(passwordDialog.userNameLineEdit->text());
-        auth->setPassword(passwordDialog.passwordLineEdit->text());
-    }
-}
-
-void NetworkAccessManager::proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *auth)
-{
-    BrowserMainWindow *mainWindow = BrowserApplication::instance()->mainWindow();
-
-    QDialog dialog(mainWindow);
-    dialog.setWindowFlags(Qt::Sheet);
-
-    Ui::ProxyDialog proxyDialog;
-    proxyDialog.setupUi(&dialog);
-
-    proxyDialog.iconLabel->setText(QString());
-    proxyDialog.iconLabel->setPixmap(mainWindow->style()->standardIcon(QStyle::SP_MessageBoxQuestion, 0, mainWindow).pixmap(32, 32));
-
-    QString introMessage = tr("<qt>Connect to proxy \"%1\" using:</qt>");
-    introMessage = introMessage.arg(proxy.hostName().toHtmlEscaped());
-    proxyDialog.introLabel->setText(introMessage);
-    proxyDialog.introLabel->setWordWrap(true);
-
-    if (dialog.exec() == QDialog::Accepted) {
-        auth->setUser(proxyDialog.userNameLineEdit->text());
-        auth->setPassword(proxyDialog.passwordLineEdit->text());
-    }
-}
-
 #ifndef QT_NO_OPENSSL
 void NetworkAccessManager::sslErrors(QNetworkReply *reply, const QList<QSslError> &error)
 {
diff --git a/examples/widgets/browser/networkaccessmanager.h b/examples/widgets/browser/networkaccessmanager.h
index 8a7aaf808f1f5d4bb69f43e996976921e87912c7..54c24f86ef2b421b29b59d4e993cff620b7a3166 100644
--- a/examples/widgets/browser/networkaccessmanager.h
+++ b/examples/widgets/browser/networkaccessmanager.h
@@ -67,8 +67,6 @@ public slots:
     void requestFinished(QNetworkReply *reply);
 
 private slots:
-    void authenticationRequired(QNetworkReply *reply, QAuthenticator *auth);
-    void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *auth);
 #ifndef QT_NO_OPENSSL
     void sslErrors(QNetworkReply *reply, const QList<QSslError> &error);
 #endif
diff --git a/examples/widgets/browser/webview.cpp b/examples/widgets/browser/webview.cpp
index 7eb08d6a33fca156e52ba710f0b417b42390e3c0..193cb47977356c666f47927ce961f2d389e543c1 100644
--- a/examples/widgets/browser/webview.cpp
+++ b/examples/widgets/browser/webview.cpp
@@ -44,10 +44,13 @@
 #include "cookiejar.h"
 #include "downloadmanager.h"
 #include "networkaccessmanager.h"
+#include "ui_passworddialog.h"
+#include "ui_proxy.h"
 #include "tabwidget.h"
 #include "webview.h"
 
 #include <QtGui/QClipboard>
+#include <QtNetwork/QAuthenticator>
 #include <QtWidgets/QMenu>
 #include <QtWidgets/QMessageBox>
 #include <QtGui/QMouseEvent>
@@ -72,6 +75,10 @@ WebPage::WebPage(QObject *parent)
 #endif
     connect(this, SIGNAL(unsupportedContent(QNetworkReply*)),
             this, SLOT(handleUnsupportedContent(QNetworkReply*)));
+    connect(this, SIGNAL(authenticationRequired(const QUrl &, QAuthenticator*)),
+            SLOT(authenticationRequired(const QUrl &, QAuthenticator*)));
+    connect(this, SIGNAL(proxyAuthenticationRequired(const QUrl &, QAuthenticator *, const QString &)),
+            SLOT(proxyAuthenticationRequired(const QUrl &, QAuthenticator *, const QString &)));
 }
 
 BrowserMainWindow *WebPage::mainWindow()
@@ -249,6 +256,53 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
 #endif
 }
 
+void WebPage::authenticationRequired(const QUrl &requestUrl, QAuthenticator *auth)
+{
+    BrowserMainWindow *mainWindow = BrowserApplication::instance()->mainWindow();
+
+    QDialog dialog(mainWindow);
+    dialog.setWindowFlags(Qt::Sheet);
+
+    Ui::PasswordDialog passwordDialog;
+    passwordDialog.setupUi(&dialog);
+
+    passwordDialog.iconLabel->setText(QString());
+    passwordDialog.iconLabel->setPixmap(mainWindow->style()->standardIcon(QStyle::SP_MessageBoxQuestion, 0, mainWindow).pixmap(32, 32));
+
+    QString introMessage = tr("<qt>Enter username and password for \"%1\" at %2</qt>");
+    introMessage = introMessage.arg(auth->realm()).arg(requestUrl.toString().toHtmlEscaped());
+    passwordDialog.introLabel->setText(introMessage);
+    passwordDialog.introLabel->setWordWrap(true);
+
+    if (dialog.exec() == QDialog::Accepted) {
+        auth->setUser(passwordDialog.userNameLineEdit->text());
+        auth->setPassword(passwordDialog.passwordLineEdit->text());
+    }
+}
+
+void WebPage::proxyAuthenticationRequired(const QUrl &requestUrl, QAuthenticator *auth, const QString &proxyHost)
+{
+    BrowserMainWindow *mainWindow = BrowserApplication::instance()->mainWindow();
+
+    QDialog dialog(mainWindow);
+    dialog.setWindowFlags(Qt::Sheet);
+
+    Ui::ProxyDialog proxyDialog;
+    proxyDialog.setupUi(&dialog);
+
+    proxyDialog.iconLabel->setText(QString());
+    proxyDialog.iconLabel->setPixmap(mainWindow->style()->standardIcon(QStyle::SP_MessageBoxQuestion, 0, mainWindow).pixmap(32, 32));
+
+    QString introMessage = tr("<qt>Connect to proxy \"%1\" using:</qt>");
+    introMessage = introMessage.arg(proxyHost.toHtmlEscaped());
+    proxyDialog.introLabel->setText(introMessage);
+    proxyDialog.introLabel->setWordWrap(true);
+
+    if (dialog.exec() == QDialog::Accepted) {
+        auth->setUser(proxyDialog.userNameLineEdit->text());
+        auth->setPassword(proxyDialog.passwordLineEdit->text());
+    }
+}
 
 WebView::WebView(QWidget* parent)
     : QWebEngineView(parent)
diff --git a/examples/widgets/browser/webview.h b/examples/widgets/browser/webview.h
index 0dce3e029a7a9c759f7f1fac1d151f273a8b9669..2d3ec50cc4eb6ce2c011384788f8dfa1d94e2c7b 100644
--- a/examples/widgets/browser/webview.h
+++ b/examples/widgets/browser/webview.h
@@ -72,6 +72,8 @@ protected:
 
 private slots:
     void handleUnsupportedContent(QNetworkReply *reply);
+    void authenticationRequired(const QUrl &requestUrl, QAuthenticator *auth);
+    void proxyAuthenticationRequired(const QUrl &requestUrl, QAuthenticator *auth, const QString &proxyHost);
 
 private:
     friend class WebView;
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp
index 7e06aed658d3d6c09ab5fb2189332f5a5c1c4285..99862235fc9431c9835ea45a78aed9454abcd0c9 100644
--- a/src/core/content_browser_client_qt.cpp
+++ b/src/core/content_browser_client_qt.cpp
@@ -44,8 +44,9 @@
 #include "base/message_loop/message_loop.h"
 #include "base/threading/thread_restrictions.h"
 #include "content/public/browser/browser_main_parts.h"
-#include "content/public/common/main_function_params.h"
 #include "content/public/browser/child_process_security_policy.h"
+#include "content/public/browser/resource_dispatcher_host.h"
+#include "content/public/common/main_function_params.h"
 #include "content/public/common/url_constants.h"
 #include "ui/gl/gl_context.h"
 #include "ui/gl/gl_implementation.h"
@@ -53,6 +54,7 @@
 
 #include "browser_context_qt.h"
 #include "dev_tools_http_handler_delegate_qt.h"
+#include "resource_dispatcher_host_delegate_qt.h"
 #include "web_contents_view_qt.h"
 
 #include <QGuiApplication>
@@ -288,6 +290,12 @@ void ContentBrowserClientQt::RenderProcessHostCreated(content::RenderProcessHost
     content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme(host->GetID(), chrome::kFileScheme);
 }
 
+void ContentBrowserClientQt::ResourceDispatcherHostCreated()
+{
+    m_resourceDispatcherHostDelegate.reset(new ResourceDispatcherHostDelegateQt);
+    content::ResourceDispatcherHost::Get()->SetDelegate(m_resourceDispatcherHostDelegate.get());
+}
+
 gfx::GLShareGroup *ContentBrowserClientQt::GetInProcessGpuShareGroup()
 {
     if (!m_shareGroupQtQuick)
diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h
index b97eaa5e1ad824b2a802892810ae661844c3a36a..c8afc633a1a7529bf6ef1efcd11f9c1635adcfcd 100644
--- a/src/core/content_browser_client_qt.h
+++ b/src/core/content_browser_client_qt.h
@@ -68,6 +68,7 @@ class GLShareGroup;
 class BrowserContextQt;
 class BrowserMainPartsQt;
 class DevToolsHttpHandlerDelegateQt;
+class ResourceDispatcherHostDelegateQt;
 class ShareGroupQtQuick;
 
 class ContentBrowserClientQt : public content::ContentBrowserClient {
@@ -79,6 +80,7 @@ public:
     virtual content::WebContentsViewPort* OverrideCreateWebContentsView(content::WebContents* , content::RenderViewHostDelegateView**) Q_DECL_OVERRIDE;
     virtual content::BrowserMainParts* CreateBrowserMainParts(const content::MainFunctionParams&) Q_DECL_OVERRIDE;
     virtual void RenderProcessHostCreated(content::RenderProcessHost* host) Q_DECL_OVERRIDE;
+    virtual void ResourceDispatcherHostCreated() Q_DECL_OVERRIDE;
     virtual gfx::GLShareGroup* GetInProcessGpuShareGroup() Q_DECL_OVERRIDE;
 
     BrowserContextQt* browser_context();
@@ -90,6 +92,7 @@ public:
 private:
     BrowserMainPartsQt* m_browserMainParts;
     scoped_ptr<DevToolsHttpHandlerDelegateQt> m_devtools;
+    scoped_ptr<ResourceDispatcherHostDelegateQt> m_resourceDispatcherHostDelegate;
     scoped_refptr<ShareGroupQtQuick> m_shareGroupQtQuick;
 };
 
diff --git a/src/core/core_gyp_generator.pro b/src/core/core_gyp_generator.pro
index bf7cce9fe221b2528347ddffb358af48f38fca42..7b0e36e0e6ccca54f7c04ac442fa4748ecd86c96 100644
--- a/src/core/core_gyp_generator.pro
+++ b/src/core/core_gyp_generator.pro
@@ -52,6 +52,7 @@ SOURCES = \
         renderer/qt_render_view_observer.cpp \
         resource_bundle_qt.cpp \
         resource_context_qt.cpp \
+        resource_dispatcher_host_delegate_qt.cpp \
         stream_video_node.cpp \
         url_request_context_getter_qt.cpp \
         web_contents_adapter.cpp \
@@ -87,6 +88,7 @@ HEADERS = \
         renderer/content_renderer_client_qt.h \
         renderer/qt_render_view_observer.h \
         resource_context_qt.h \
+        resource_dispatcher_host_delegate_qt.h \
         stream_video_node.h \
         url_request_context_getter_qt.h \
         web_contents_adapter.h \
diff --git a/src/core/resource_dispatcher_host_delegate_qt.cpp b/src/core/resource_dispatcher_host_delegate_qt.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3e650afb706187e49881f223bfe3e11238b810f1
--- /dev/null
+++ b/src/core/resource_dispatcher_host_delegate_qt.cpp
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.  For licensing terms and
+** conditions see http://qt.digia.com/licensing.  For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights.  These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "resource_dispatcher_host_delegate_qt.h"
+
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/resource_dispatcher_host.h"
+#include "content/public/browser/resource_request_info.h"
+#include "net/url_request/url_request.h"
+
+#include "type_conversion.h"
+#include "web_contents_view_qt.h"
+
+ResourceDispatcherHostLoginDelegateQt::ResourceDispatcherHostLoginDelegateQt(net::AuthChallengeInfo *authInfo, net::URLRequest *request)
+    : m_request(request)
+{
+    Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+    content::ResourceRequestInfo::ForRequest(request)->GetAssociatedRenderView(&m_renderProcessId,  &m_renderViewId);
+
+    m_url = toQt(request->url());
+    m_realm = QString::fromStdString(authInfo->realm);
+    m_isProxy = authInfo->is_proxy;
+    m_host = QString::fromStdString(authInfo->challenger.ToString());
+
+    content::BrowserThread::PostTask(
+        content::BrowserThread::UI, FROM_HERE,
+        base::Bind(&ResourceDispatcherHostLoginDelegateQt::triggerDialog, this));
+}
+
+ResourceDispatcherHostLoginDelegateQt::~ResourceDispatcherHostLoginDelegateQt()
+{
+    // We must have called ClearLoginDelegateForRequest if we didn't receive an OnRequestCancelled.
+    Q_ASSERT(!m_request);
+}
+
+void ResourceDispatcherHostLoginDelegateQt::OnRequestCancelled()
+{
+    m_request = 0;
+}
+
+void ResourceDispatcherHostLoginDelegateQt::triggerDialog()
+{
+    Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+    content::RenderViewHost* renderViewHost = content::RenderViewHost::FromID(m_renderProcessId, m_renderViewId);
+    content::WebContents *webContents = content::WebContents::FromRenderViewHost(renderViewHost);
+    WebContentsAdapterClient *client = WebContentsViewQt::from(webContents->GetView())->client();
+
+    // The widgets API will ask for credentials synchronouly, keep it simple for now.
+    // We'll have to figure out a mechanism to keep a ref to the ResourceDispatcherHostLoginDelegateQt
+    // to avoid crashing in the OnRequestCancelled case if we want to allow the credentials to
+    // come back asynchronously in the QtQuick API.
+    QString user, password;
+    client->authenticationRequired(m_url , m_realm , m_isProxy , m_host, &user, &password);
+
+    bool success = !user.isEmpty() || !password.isEmpty();
+    content::BrowserThread::PostTask(
+        content::BrowserThread::IO, FROM_HERE,
+        base::Bind(&ResourceDispatcherHostLoginDelegateQt::sendAuthToRequester, this, success, user, password));
+}
+
+void ResourceDispatcherHostLoginDelegateQt::sendAuthToRequester(bool success, const QString &user, const QString &password)
+{
+    Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+    if (!m_request)
+        return;
+
+    if (success)
+        m_request->SetAuth(net::AuthCredentials(toString16(user), toString16(password)));
+    else
+        m_request->CancelAuth();
+    content::ResourceDispatcherHost::Get()->ClearLoginDelegateForRequest(m_request);
+
+    m_request = 0;
+}
+
+bool ResourceDispatcherHostDelegateQt::AcceptAuthRequest(net::URLRequest *, net::AuthChallengeInfo *)
+{
+    return true;
+}
+
+content::ResourceDispatcherHostLoginDelegate *ResourceDispatcherHostDelegateQt::CreateLoginDelegate(net::AuthChallengeInfo *authInfo, net::URLRequest *request)
+{
+    // ResourceDispatcherHostLoginDelegateQt is ref-counted and will be released after we called ClearLoginDelegateForRequest.
+    return new ResourceDispatcherHostLoginDelegateQt(authInfo, request);
+}
diff --git a/src/core/resource_dispatcher_host_delegate_qt.h b/src/core/resource_dispatcher_host_delegate_qt.h
new file mode 100644
index 0000000000000000000000000000000000000000..1b584912e42149592c5677c90fc20e475681d0a0
--- /dev/null
+++ b/src/core/resource_dispatcher_host_delegate_qt.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.  For licensing terms and
+** conditions see http://qt.digia.com/licensing.  For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights.  These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef RESOURCE_DISPATCHER_HOST_DELEGATE_QT_H
+#define RESOURCE_DISPATCHER_HOST_DELEGATE_QT_H
+
+#include "content/public/browser/resource_dispatcher_host_delegate.h"
+#include "content/public/browser/resource_dispatcher_host_login_delegate.h"
+
+#include "web_contents_adapter_client.h"
+
+class ResourceDispatcherHostLoginDelegateQt : public content::ResourceDispatcherHostLoginDelegate {
+public:
+    ResourceDispatcherHostLoginDelegateQt(net::AuthChallengeInfo *authInfo, net::URLRequest *request);
+    ~ResourceDispatcherHostLoginDelegateQt();
+
+    // ResourceDispatcherHostLoginDelegate implementation
+    virtual void OnRequestCancelled();
+
+private:
+    void triggerDialog();
+    void sendAuthToRequester(bool success, const QString &user, const QString &password);
+
+    QUrl m_url;
+    QString m_realm;
+    bool m_isProxy;
+    QString m_host;
+
+    int m_renderProcessId;
+    int m_renderViewId;
+
+    // The request that wants login data.
+    // Must only be accessed on the IO thread.
+    net::URLRequest *m_request;
+};
+
+class ResourceDispatcherHostDelegateQt : public content::ResourceDispatcherHostDelegate {
+public:
+    virtual bool AcceptAuthRequest(net::URLRequest *request, net::AuthChallengeInfo *authInfo) Q_DECL_OVERRIDE;
+    virtual content::ResourceDispatcherHostLoginDelegate* CreateLoginDelegate(net::AuthChallengeInfo *authInfo, net::URLRequest *request) Q_DECL_OVERRIDE;
+};
+
+#endif // RESOURCE_DISPATCHER_HOST_DELEGATE_QT_H
diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h
index f56e31a7174c22298bb52b81199646fb5a5e3299..e436fd61dc4e1dc22b3808a21449c2a5e79e68e5 100644
--- a/src/core/web_contents_adapter_client.h
+++ b/src/core/web_contents_adapter_client.h
@@ -139,6 +139,7 @@ public:
     virtual void didFindText(quint64 requestId, int matchCount) = 0;
     virtual void passOnFocus(bool reverse) = 0;
     virtual void javaScriptConsoleMessage(int level, const QString& message, int lineNumber, const QString& sourceID) = 0;
+    virtual void authenticationRequired(const QUrl &requestUrl, const QString &realm, bool isProxy, const QString &challengingHost, QString *outUser, QString *outPassword) = 0;
 };
 
 #endif // WEB_CONTENTS_ADAPTER_CLIENT_H
diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h
index 5c75f778033771c77cdcc926aecdfd0f5c94e057..7fed546d471fee9f52149e096b12239cf7c22605 100644
--- a/src/webengine/api/qquickwebengineview_p_p.h
+++ b/src/webengine/api/qquickwebengineview_p_p.h
@@ -145,6 +145,7 @@ public:
     virtual void didFindText(quint64, int) Q_DECL_OVERRIDE { }
     virtual void passOnFocus(bool reverse) Q_DECL_OVERRIDE;
     virtual void javaScriptConsoleMessage(int level, const QString& message, int lineNumber, const QString& sourceID) Q_DECL_OVERRIDE;
+    virtual void authenticationRequired(const QUrl&, const QString&, bool, const QString&, QString*, QString*) Q_DECL_OVERRIDE { }
 
     void setDevicePixelRatio(qreal);
     void adoptWebContents(WebContentsAdapter *webContents);
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index 83f77b4bdf5e49aede6cbafc468c0934377806dc..4c4243cccada5a30b81b780ce8acae60b168ea36 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -42,6 +42,7 @@
 #include <QMessageBox>
 #include <QStandardPaths>
 #include <QUrl>
+#include <private/qauthenticator_p.h>
 
 QT_BEGIN_NAMESPACE
 
@@ -284,6 +285,22 @@ void QWebEnginePagePrivate::didFindText(quint64 requestId, int matchCount)
     m_callbacks.invoke(requestId, matchCount > 0);
 }
 
+void QWebEnginePagePrivate::authenticationRequired(const QUrl &requestUrl, const QString &realm, bool isProxy, const QString &challengingHost, QString *outUser, QString *outPassword)
+{
+    Q_Q(QWebEnginePage);
+    QAuthenticator networkAuth;
+    // Detach to trigger the creation of its QAuthenticatorPrivate.
+    networkAuth.detach();
+    QAuthenticatorPrivate::getPrivate(networkAuth)->realm = realm;
+
+    if (isProxy)
+        Q_EMIT q->proxyAuthenticationRequired(requestUrl, &networkAuth, challengingHost);
+    else
+        Q_EMIT q->authenticationRequired(requestUrl, &networkAuth);
+    *outUser = networkAuth.user();
+    *outPassword = networkAuth.password();
+}
+
 void QWebEnginePagePrivate::updateAction(QWebEnginePage::WebAction action) const
 {
 #ifdef QT_NO_ACTION
diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h
index 96ffeda3a7aa663a37b6863661b8305de9890af0..04db9975053c422cfe2310d48f86d0dba1b0bd60 100644
--- a/src/webenginewidgets/api/qwebenginepage.h
+++ b/src/webenginewidgets/api/qwebenginepage.h
@@ -542,6 +542,9 @@ Q_SIGNALS:
     void featurePermissionRequested(QWebEngineFrame* frame, QWebEnginePage::Feature feature);
     void featurePermissionRequestCanceled(QWebEngineFrame* frame, QWebEnginePage::Feature feature);
 
+    void authenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator);
+    void proxyAuthenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator, const QString &proxyHost);
+
     // Ex-QWebFrame signals
     void javaScriptWindowObjectCleared();
 
diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h
index 773df00d4cebec1a5951b4774999ff9d8bcdbe4b..42f66cd01486e173fe9203b1148eddee2bea75ef 100644
--- a/src/webenginewidgets/api/qwebenginepage_p.h
+++ b/src/webenginewidgets/api/qwebenginepage_p.h
@@ -134,6 +134,7 @@ public:
     virtual void didFindText(quint64 requestId, int matchCount) Q_DECL_OVERRIDE;
     virtual void passOnFocus(bool reverse) Q_DECL_OVERRIDE { Q_UNUSED(reverse); };
     virtual void javaScriptConsoleMessage(int level, const QString& message, int lineNumber, const QString& sourceID) Q_DECL_OVERRIDE;
+    virtual void authenticationRequired(const QUrl &requestUrl, const QString &realm, bool isProxy, const QString &challengingHost, QString *outUser, QString *outPassword) Q_DECL_OVERRIDE;
 
     void updateAction(QWebEnginePage::WebAction) const;
     void updateNavigationActions();
diff --git a/src/webenginewidgets/webenginewidgets.pro b/src/webenginewidgets/webenginewidgets.pro
index 86367d771590b4a499e24fceb1bb3b9e77445517..a871586ae386366fadd3c690ca6f785c8cb89ac0 100644
--- a/src/webenginewidgets/webenginewidgets.pro
+++ b/src/webenginewidgets/webenginewidgets.pro
@@ -3,8 +3,8 @@ TARGET = QtWebEngineWidgets
 # For our export macros
 DEFINES += QT_BUILD_WEBENGINEWIDGETS_LIB
 
-QT += widgets
-QT_PRIVATE += widgets-private gui-private core-private
+QT += widgets network
+QT_PRIVATE += widgets-private gui-private network-private core-private
 
 # FIXME: all this should eventually be turned into QT += webenginecore
 macx:LIBPATH = $$getOutDir()/$$getConfigDir()