mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Cloud: Extract common oauth2 parts of Sumo and Osdu connector.
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2024 Equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QOAuth2AuthorizationCodeFlow>
|
||||
|
||||
// #include <map>
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RiaCloudConnector : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
RiaCloudConnector( QObject* parent,
|
||||
const QString& server,
|
||||
const QString& authority,
|
||||
const QString& scopes,
|
||||
const QString& clientId,
|
||||
unsigned int port );
|
||||
~RiaCloudConnector() override;
|
||||
|
||||
QString token() const;
|
||||
|
||||
void importTokenFromFile();
|
||||
void setTokenDataFilePath( const QString& filePath );
|
||||
|
||||
QString server() const;
|
||||
|
||||
public slots:
|
||||
void requestToken();
|
||||
void accessGranted();
|
||||
void requestFailed( const QAbstractOAuth::Error error );
|
||||
|
||||
signals:
|
||||
void tokenReady( const QString& token );
|
||||
|
||||
private slots:
|
||||
void errorReceived( const QString& error, const QString& errorDescription, const QUrl& uri );
|
||||
void authorizationCallbackReceived( const QVariantMap& data );
|
||||
|
||||
protected:
|
||||
QString requestTokenBlocking();
|
||||
|
||||
static QString constructAuthUrl( const QString& authority );
|
||||
static QString constructTokenUrl( const QString& authority );
|
||||
|
||||
QOAuth2AuthorizationCodeFlow* m_authCodeFlow;
|
||||
QNetworkAccessManager* m_networkAccessManager;
|
||||
|
||||
const QString m_server;
|
||||
const QString m_authority;
|
||||
const QString m_scopes;
|
||||
const QString m_clientId;
|
||||
|
||||
QString m_token;
|
||||
|
||||
QString m_tokenDataFilePath;
|
||||
};
|
||||
Reference in New Issue
Block a user