File indexing completed on 2024-12-22 04:44:57

0001 /*
0002    SPDX-FileCopyrightText: 2018-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 #include "librestapi_private_export.h"
0009 #include "restapiabstractjob.h"
0010 
0011 namespace RocketChatRestApi
0012 {
0013 class LIBROCKETCHATRESTAPI_QT_TESTS_EXPORT GoogleAuthJob : public RestApiAbstractJob
0014 {
0015     Q_OBJECT
0016 public:
0017     explicit GoogleAuthJob(QObject *parent = nullptr);
0018     ~GoogleAuthJob() override;
0019 
0020     [[nodiscard]] bool start() override;
0021     [[nodiscard]] bool requireHttpAuthentication() const override;
0022 
0023     [[nodiscard]] bool canStart() const override;
0024 
0025     [[nodiscard]] QNetworkRequest request() const override;
0026     [[nodiscard]] QJsonDocument json() const;
0027 
0028     [[nodiscard]] QString accessToken() const;
0029     void setAccessToken(const QString &accessToken);
0030 
0031     [[nodiscard]] int expireTokenInSeconds() const;
0032     void setExpireTokenInSeconds(int expireTokenInSeconds);
0033 
0034     [[nodiscard]] QString idToken() const;
0035     void setIdToken(const QString &idToken);
0036 
0037 Q_SIGNALS:
0038     void googleauthDone(const QString &authToken, const QString &userId);
0039 
0040 private:
0041     Q_DISABLE_COPY(GoogleAuthJob)
0042     void onPostRequestResponse(const QString &replyErrorString, const QJsonDocument &replyJson) override;
0043     QString mAccessToken;
0044     QString mIdToken;
0045     int mExpireTokenInSeconds = -1;
0046     // TODO identity ???? it's optional
0047 };
0048 }