#ifndef GMAILAUTHENTICATOR_H
#define GMAILAUTHENTICATOR_H

#include "authenticator.h"
#include "oauthcallbackserver.h"

class GmailAuthenticator : public Authenticator
{
    Q_OBJECT
public:
    explicit GmailAuthenticator(QObject *parent = nullptr);
    ~GmailAuthenticator() override = default;

    void authenticate(const QString &email) override;
    void refreshToken(const Account &account) override;
    QString providerName() const override { return "gmail"; }

private slots:
    void onTokenReply(QNetworkReply *reply);
    void onAuthCodeReceived(const QString &code, const QString &state);

private:
    QString m_email;
    QString m_authCode;
    OAuthCallbackServer *m_callbackServer;
};

#endif // GMAILAUTHENTICATOR_H