1 | // Copyright (C) 2017 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef QOAUTH2AUTHORIZATIONCODEFLOW_H |
5 | #define QOAUTH2AUTHORIZATIONCODEFLOW_H |
6 | |
7 | #ifndef QT_NO_HTTP |
8 | |
9 | #include <QtNetworkAuth/qoauthglobal.h> |
10 | #include <QtNetworkAuth/qabstractoauth2.h> |
11 | |
12 | QT_BEGIN_NAMESPACE |
13 | |
14 | class QUrl; |
15 | class QString; |
16 | class QNetworkAccessManager; |
17 | |
18 | class QOAuth2AuthorizationCodeFlowPrivate; |
19 | class Q_OAUTH_EXPORT QOAuth2AuthorizationCodeFlow : public QAbstractOAuth2 |
20 | { |
21 | Q_OBJECT |
22 | Q_PROPERTY(QUrl accessTokenUrl |
23 | READ accessTokenUrl |
24 | WRITE setAccessTokenUrl |
25 | NOTIFY accessTokenUrlChanged) |
26 | |
27 | public: |
28 | explicit QOAuth2AuthorizationCodeFlow(QObject *parent = nullptr); |
29 | explicit QOAuth2AuthorizationCodeFlow(QNetworkAccessManager *manager, |
30 | QObject *parent = nullptr); |
31 | |
32 | QOAuth2AuthorizationCodeFlow(const QString &clientIdentifier, |
33 | QNetworkAccessManager *manager, |
34 | QObject *parent = nullptr); |
35 | |
36 | QOAuth2AuthorizationCodeFlow(const QUrl &authorizationUrl, |
37 | const QUrl &accessTokenUrl, |
38 | QNetworkAccessManager *manager, |
39 | QObject *parent = nullptr); |
40 | |
41 | QOAuth2AuthorizationCodeFlow(const QString &clientIdentifier, |
42 | const QUrl &authorizationUrl, |
43 | const QUrl &accessTokenUrl, |
44 | QNetworkAccessManager *manager, |
45 | QObject *parent = nullptr); |
46 | |
47 | ~QOAuth2AuthorizationCodeFlow(); |
48 | |
49 | QUrl accessTokenUrl() const; |
50 | void setAccessTokenUrl(const QUrl &accessTokenUrl); |
51 | |
52 | public Q_SLOTS: |
53 | void grant() override; |
54 | void refreshAccessToken(); |
55 | |
56 | protected: |
57 | QUrl buildAuthenticateUrl(const QMultiMap<QString, QVariant> ¶meters = {}); |
58 | void requestAccessToken(const QString &code); |
59 | void resourceOwnerAuthorization(const QUrl &url, |
60 | const QMultiMap<QString, QVariant> ¶meters = {}) override; |
61 | |
62 | Q_SIGNALS: |
63 | void accessTokenUrlChanged(const QUrl &accessTokenUrl); |
64 | |
65 | private: |
66 | Q_DISABLE_COPY(QOAuth2AuthorizationCodeFlow) |
67 | Q_DECLARE_PRIVATE(QOAuth2AuthorizationCodeFlow) |
68 | }; |
69 | |
70 | QT_END_NAMESPACE |
71 | |
72 | #endif // QT_NO_HTTP |
73 | |
74 | #endif // QOAUTH2AUTHORIZATIONCODEFLOW_H |
75 | |