-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgithubauth.h
More file actions
38 lines (32 loc) · 958 Bytes
/
Copy pathgithubauth.h
File metadata and controls
38 lines (32 loc) · 958 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef GITHUBAUTH_H
#define GITHUBAUTH_H
#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QTimer>
#include <QJsonObject>
#include <QJsonDocument>
#include <QUrl>
class GithubAuth : public QObject {
Q_OBJECT
public:
explicit GithubAuth(QObject *parent = nullptr);
void initiateAuth();
void fetchUserProfile(const QString &token);
signals:
void userCodeReceived(const QString &userCode, const QString &verificationUri);
void authenticated(const QString &accessToken);
void profileDataReceived(const QString &avatarUrl, const QString &login, const QString &name);
void errorOccurred(const QString &errorMsg);
private slots:
void onDeviceCodeReply();
void pollAccessToken();
void onAccessTokenReply();
void onProfileReply();
private:
QNetworkAccessManager *m_nam;
QString m_clientId;
QString m_deviceCode;
QTimer *m_pollTimer;
};
#endif // GITHUBAUTH_H