| 1 | // Copyright (C) 2017 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | // |
| 5 | // W A R N I N G |
| 6 | // ------------- |
| 7 | // |
| 8 | // This file is not part of the Qt API. It exists for the convenience |
| 9 | // of the Network Access API. This header file may change from |
| 10 | // version to version without notice, or even be removed. |
| 11 | // |
| 12 | // We mean it. |
| 13 | // |
| 14 | |
| 15 | #ifndef QOAUTH2AUTHORIZATIONCODEFLOW_P_H |
| 16 | #define QOAUTH2AUTHORIZATIONCODEFLOW_P_H |
| 17 | |
| 18 | #include <private/qabstractoauth2_p.h> |
| 19 | |
| 20 | #include <QtNetworkAuth/qoauthglobal.h> |
| 21 | #include <QtNetworkAuth/qoauth2authorizationcodeflow.h> |
| 22 | |
| 23 | #include <QtCore/qpointer.h> |
| 24 | #include <QtCore/qstring.h> |
| 25 | #include <QtCore/qdatetime.h> |
| 26 | |
| 27 | QT_BEGIN_NAMESPACE |
| 28 | |
| 29 | class QOAuth2AuthorizationCodeFlowPrivate : public QAbstractOAuth2Private |
| 30 | { |
| 31 | public: |
| 32 | Q_DECLARE_PUBLIC(QOAuth2AuthorizationCodeFlow) |
| 33 | |
| 34 | QOAuth2AuthorizationCodeFlowPrivate(const QUrl &authorizationUrl, |
| 35 | const QUrl &accessTokenUrl, |
| 36 | const QString &clientIdentifier, |
| 37 | QNetworkAccessManager *manager = nullptr); |
| 38 | |
| 39 | void _q_handleCallback(const QVariantMap &data); |
| 40 | void _q_accessTokenRequestFinished(const QVariantMap &values); |
| 41 | void _q_accessTokenRequestFailed(QAbstractOAuth::Error error, const QString &errorString = {}); |
| 42 | void _q_authenticate(QNetworkReply *reply, QAuthenticator *authenticator); |
| 43 | |
| 44 | QByteArray createPKCEChallenge(); |
| 45 | |
| 46 | QOAuth2AuthorizationCodeFlow::PkceMethod pkceMethod |
| 47 | = QOAuth2AuthorizationCodeFlow::PkceMethod::S256; |
| 48 | quint8 pkceVerifierLength = 43; // RFC 7636 Section 4.1 |
| 49 | QByteArray pkceCodeVerifier; |
| 50 | |
| 51 | QUrl accessTokenUrl; |
| 52 | QString tokenType; |
| 53 | QPointer<QNetworkReply> currentReply; |
| 54 | }; |
| 55 | |
| 56 | QT_END_NAMESPACE |
| 57 | |
| 58 | #endif // QOAUTH2AUTHORIZATIONCODEFLOW_P_H |
| 59 |
