| 1 | // Copyright (C) 2017 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QABSTRACTOAUTH2_H |
| 5 | #define QABSTRACTOAUTH2_H |
| 6 | |
| 7 | #include <QtNetworkAuth/qoauthglobal.h> |
| 8 | |
| 9 | #ifndef QT_NO_HTTP |
| 10 | |
| 11 | #include <QtCore/qdatetime.h> |
| 12 | |
| 13 | #include <QtNetworkAuth/qabstractoauth.h> |
| 14 | |
| 15 | QT_BEGIN_NAMESPACE |
| 16 | |
| 17 | class QSslConfiguration; |
| 18 | class QHttpMultiPart; |
| 19 | class QAbstractOAuth2Private; |
| 20 | class Q_OAUTH_EXPORT QAbstractOAuth2 : public QAbstractOAuth |
| 21 | { |
| 22 | Q_OBJECT |
| 23 | Q_PROPERTY(QString scope READ scope WRITE setScope NOTIFY scopeChanged) |
| 24 | Q_PROPERTY(QString userAgent READ userAgent WRITE setUserAgent NOTIFY userAgentChanged) |
| 25 | Q_PROPERTY(QString clientIdentifierSharedKey |
| 26 | READ clientIdentifierSharedKey |
| 27 | WRITE setClientIdentifierSharedKey |
| 28 | NOTIFY clientIdentifierSharedKeyChanged) |
| 29 | Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged) |
| 30 | Q_PROPERTY(QDateTime expiration READ expirationAt NOTIFY expirationAtChanged) |
| 31 | Q_PROPERTY(QString refreshToken |
| 32 | READ refreshToken |
| 33 | WRITE setRefreshToken |
| 34 | NOTIFY refreshTokenChanged) |
| 35 | |
| 36 | public: |
| 37 | explicit QAbstractOAuth2(QObject *parent = nullptr); |
| 38 | explicit QAbstractOAuth2(QNetworkAccessManager *manager, QObject *parent = nullptr); |
| 39 | ~QAbstractOAuth2(); |
| 40 | |
| 41 | Q_INVOKABLE virtual QUrl createAuthenticatedUrl(const QUrl &url, |
| 42 | const QVariantMap ¶meters = QVariantMap()); |
| 43 | |
| 44 | QT_DEPRECATED_VERSION_X_6_11("Use QtNetwork classes instead." |
| 45 | "See https://doc.qt.io/qt-6/oauth-http-method-alternatives.html" ) |
| 46 | Q_INVOKABLE QNetworkReply *(const QUrl &url, |
| 47 | const QVariantMap ¶meters = QVariantMap()) override; |
| 48 | |
| 49 | QT_DEPRECATED_VERSION_X_6_11("Use QtNetwork classes instead." |
| 50 | "See https://doc.qt.io/qt-6/oauth-http-method-alternatives.html" ) |
| 51 | Q_INVOKABLE QNetworkReply *get(const QUrl &url, |
| 52 | const QVariantMap ¶meters = QVariantMap()) override; |
| 53 | |
| 54 | QT_DEPRECATED_VERSION_X_6_11("Use QtNetwork classes instead." |
| 55 | "See https://doc.qt.io/qt-6/oauth-http-method-alternatives.html" ) |
| 56 | Q_INVOKABLE QNetworkReply *post(const QUrl &url, |
| 57 | const QVariantMap ¶meters = QVariantMap()) override; |
| 58 | |
| 59 | QT_DEPRECATED_VERSION_X_6_11("Use QtNetwork classes instead." |
| 60 | "See https://doc.qt.io/qt-6/oauth-http-method-alternatives.html" ) |
| 61 | Q_INVOKABLE virtual QNetworkReply *post(const QUrl &url, const QByteArray &data); |
| 62 | |
| 63 | QT_DEPRECATED_VERSION_X_6_11("Use QtNetwork classes instead." |
| 64 | "See https://doc.qt.io/qt-6/oauth-http-method-alternatives.html" ) |
| 65 | Q_INVOKABLE virtual QNetworkReply *post(const QUrl &url, QHttpMultiPart *multiPart); |
| 66 | |
| 67 | QT_DEPRECATED_VERSION_X_6_11("Use QtNetwork classes instead." |
| 68 | "See https://doc.qt.io/qt-6/oauth-http-method-alternatives.html" ) |
| 69 | Q_INVOKABLE QNetworkReply *put(const QUrl &url, |
| 70 | const QVariantMap ¶meters = QVariantMap()) override; |
| 71 | |
| 72 | QT_DEPRECATED_VERSION_X_6_11("Use QtNetwork classes instead." |
| 73 | "See https://doc.qt.io/qt-6/oauth-http-method-alternatives.html" ) |
| 74 | Q_INVOKABLE virtual QNetworkReply *put(const QUrl &url, const QByteArray &data); |
| 75 | |
| 76 | QT_DEPRECATED_VERSION_X_6_11("Use QtNetwork classes instead." |
| 77 | "See https://doc.qt.io/qt-6/oauth-http-method-alternatives.html" ) |
| 78 | Q_INVOKABLE virtual QNetworkReply *put(const QUrl &url, QHttpMultiPart *multiPart); |
| 79 | |
| 80 | QT_DEPRECATED_VERSION_X_6_11("Use QtNetwork classes instead." |
| 81 | "See https://doc.qt.io/qt-6/oauth-http-method-alternatives.html" ) |
| 82 | Q_INVOKABLE QNetworkReply *deleteResource(const QUrl &url, |
| 83 | const QVariantMap ¶meters = QVariantMap()) override; |
| 84 | |
| 85 | QString scope() const; |
| 86 | void setScope(const QString &scope); |
| 87 | |
| 88 | QString userAgent() const; |
| 89 | void setUserAgent(const QString &userAgent); |
| 90 | |
| 91 | QString responseType() const; |
| 92 | |
| 93 | QString clientIdentifierSharedKey() const; |
| 94 | void setClientIdentifierSharedKey(const QString &clientIdentifierSharedKey); |
| 95 | |
| 96 | QString state() const; |
| 97 | void setState(const QString &state); |
| 98 | |
| 99 | QDateTime expirationAt() const; |
| 100 | |
| 101 | QString refreshToken() const; |
| 102 | void setRefreshToken(const QString &refreshToken); |
| 103 | |
| 104 | #ifndef QT_NO_SSL |
| 105 | QSslConfiguration sslConfiguration() const; |
| 106 | void setSslConfiguration(const QSslConfiguration &configuration); |
| 107 | #endif |
| 108 | |
| 109 | void prepareRequest(QNetworkRequest *request, const QByteArray &verb, |
| 110 | const QByteArray &body = QByteArray()) override; |
| 111 | |
| 112 | Q_SIGNALS: |
| 113 | void scopeChanged(const QString &scope); |
| 114 | void userAgentChanged(const QString &userAgent); |
| 115 | void responseTypeChanged(const QString &responseType); |
| 116 | void clientIdentifierSharedKeyChanged(const QString &clientIdentifierSharedKey); |
| 117 | void stateChanged(const QString &state); |
| 118 | void expirationAtChanged(const QDateTime &expiration); |
| 119 | void refreshTokenChanged(const QString &refreshToken); |
| 120 | #ifndef QT_NO_SSL |
| 121 | void sslConfigurationChanged(const QSslConfiguration &configuration); |
| 122 | #endif |
| 123 | |
| 124 | void error(const QString &error, const QString &errorDescription, const QUrl &uri); |
| 125 | void authorizationCallbackReceived(const QVariantMap &data); |
| 126 | |
| 127 | protected: |
| 128 | explicit QAbstractOAuth2(QAbstractOAuth2Private &, QObject *parent = nullptr); |
| 129 | |
| 130 | void setResponseType(const QString &responseType); |
| 131 | |
| 132 | private: |
| 133 | Q_DECLARE_PRIVATE(QAbstractOAuth2) |
| 134 | }; |
| 135 | |
| 136 | QT_END_NAMESPACE |
| 137 | |
| 138 | #endif // QT_NO_HTTP |
| 139 | |
| 140 | #endif // QABSTRACTOAUTH2_H |
| 141 | |