Quark  0.1
OAuth2Authenticator.h++
Go to the documentation of this file.
1 #ifndef __libquark_oauth2_OAuth2Authenticator_hxx
2 #define __libquark_oauth2_OAuth2Authenticator_hxx
3 
4 #include <QByteArray>
5 #include <QNetworkAccessManager>
6 #include <QNetworkReply>
7 #include <QString>
8 #include <QStringList>
9 #include <QUrl>
10 
11 #include <quark/Quark.h++>
13 
14 namespace quark {
15 namespace oauth2 {
16 
38 class LIBQUARK_API OAuth2Authenticator : public QObject
39 {
40  Q_OBJECT;
41 
42  public:
43 
53  OAuth2Authenticator(QNetworkAccessManager *networkAccess,
54  const QString &clientID,
55  const QString &clientSecret,
56  QObject *parent = NULL);
57 
59  virtual ~OAuth2Authenticator();
60 
70  QUrl buildAuthUrl(const QStringList &authScopes);
71 
79  bool requestAccessToken(const QString &authorizationCode);
80 
90  bool renewAccessToken(const QString &refreshToken);
91 
96  { return(_accessToken); }
97 
98  signals:
99 
104  void accessTokenError(const QString &error);
105 
109  void accessTokenReceived();
110 
111  private slots:
112 
113  void processPostReply();
114  void processPostError(QNetworkReply::NetworkError);
115 
116  private:
117 
118  void performPost(const QUrl &url, const QByteArray &postData);
119 
120  QNetworkAccessManager *_networkAccess;
121  QString _clientID;
122  QString _clientSecret;
123  QString _codeVerifier;
124  OAuth2AccessToken _accessToken;
125  QString _refreshToken;
126  bool _requestInProgress;
127 };
128 
129 } // namespace oauth2
130 } // namespace quark
131 
132 #endif // __libquark_oauth2_OAuth2Authenticator_hxx
Definition: BarChartView.h++:6
A representation of an OAuth2 access token.
Definition: OAuth2AccessToken.h++:17
An object for performing OAuth2 authorizations for accessing Google APIs.
Definition: OAuth2Authenticator.h++:38
#define LIBQUARK_API
Definition: Quark.h++:18
OAuth2AccessToken accessToken() const
Returns the OAuth2AccessToken.
Definition: OAuth2Authenticator.h++:95