| 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 QABSTRACTOAUTH2_P_H |
| 16 | #define QABSTRACTOAUTH2_P_H |
| 17 | |
| 18 | #include <optional> |
| 19 | |
| 20 | #include <private/qabstractoauth_p.h> |
| 21 | |
| 22 | #include <QtNetworkAuth/qoauthglobal.h> |
| 23 | #include <QtNetworkAuth/qabstractoauth2.h> |
| 24 | |
| 25 | #include <QtCore/qurl.h> |
| 26 | #include <QtCore/qstring.h> |
| 27 | #include <QtCore/qpointer.h> |
| 28 | |
| 29 | #include <QtNetwork/qnetworkreply.h> |
| 30 | |
| 31 | #include <utility> |
| 32 | |
| 33 | QT_BEGIN_NAMESPACE |
| 34 | |
| 35 | class QNetworkAccessManager; |
| 36 | |
| 37 | class QAbstractOAuth2Private : public QAbstractOAuthPrivate |
| 38 | { |
| 39 | Q_DECLARE_PUBLIC(QAbstractOAuth2) |
| 40 | |
| 41 | public: |
| 42 | QAbstractOAuth2Private(const std::pair<QString, QString> &clientCredentials, |
| 43 | const QUrl &authorizationUrl, QNetworkAccessManager *manager = nullptr); |
| 44 | ~QAbstractOAuth2Private(); |
| 45 | |
| 46 | void setExpiresAt(const QDateTime &expiration); |
| 47 | static QString generateRandomState(); |
| 48 | QNetworkRequest createRequest(QUrl url, const QVariantMap *parameters = nullptr); |
| 49 | |
| 50 | QString clientIdentifierSharedKey; |
| 51 | QString scope; |
| 52 | QString state = generateRandomState(); |
| 53 | QString userAgent = QStringLiteral("QtOAuth/1.0 (+https://www.qt.io)" ); |
| 54 | QString responseType; |
| 55 | const QString bearerFormat = QStringLiteral("Bearer %1" ); // Case sensitive |
| 56 | QDateTime expiresAtUtc; |
| 57 | QString refreshToken; |
| 58 | #ifndef QT_NO_SSL |
| 59 | std::optional<QSslConfiguration> sslConfiguration; |
| 60 | #endif |
| 61 | |
| 62 | struct OAuth2KeyString |
| 63 | { |
| 64 | static const QString accessToken; |
| 65 | static const QString apiKey; |
| 66 | static const QString clientIdentifier; |
| 67 | static const QString clientSharedSecret; |
| 68 | static const QString code; |
| 69 | static const QString error; |
| 70 | static const QString errorDescription; |
| 71 | static const QString errorUri; |
| 72 | static const QString expiresIn; |
| 73 | static const QString grantType; |
| 74 | static const QString redirectUri; |
| 75 | static const QString refreshToken; |
| 76 | static const QString responseType; |
| 77 | static const QString scope; |
| 78 | static const QString state; |
| 79 | static const QString tokenType; |
| 80 | static const QString codeVerifier; |
| 81 | static const QString codeChallenge; |
| 82 | static const QString codeChallengeMethod; |
| 83 | }; |
| 84 | }; |
| 85 | |
| 86 | QT_END_NAMESPACE |
| 87 | |
| 88 | #endif // QABSTRACTOAUTH2_P_H |
| 89 | |