Fledge
An open source edge computing platform for industrial users
ocs.h
1 #ifndef _OCS_H
2 #define _OCS_H
3 /*
4  * Fledge OSIsoft ADH and OCS integration.
5  *
6  * Copyright (c) 2020-2025 Dianomic Systems
7  *
8  * Released under the Apache 2.0 Licence
9  *
10  * Author: Stefano Simonelli
11  */
12 
13 #include <string>
14 #include <chrono>
15 
16 using namespace std;
17 
18 #define TIMEOUT_CONNECT 10
19 #define TIMEOUT_REQUEST 10
20 #define RETRY_SLEEP_TIME 1
21 
22 #define URL_RETRIEVE_TOKEN "/identity/connect/token"
23 
24 #define PAYLOAD_RETRIEVE_TOKEN "grant_type=client_credentials&client_id=CLIENT_ID_PLACEHOLDER&client_secret=CLIENT_SECRET_ID_PLACEHOLDER"
25 
29 class OCS
30 {
31  public:
32  OCS(const std::string &authorizationUrl);
33 
34  // Destructor
35  ~OCS();
36 
37  std::string OCSRetrieveAuthToken(const string& clientId, const string& clientSecret, bool logMessage = true);
38  int retrieveToken(const string& clientId, const string& clientSecret, bool logMessage = true);
39  void extractToken(const string& response);
40  private:
41  std::string m_token;
42  std::string m_authUrl;
43  unsigned int m_expiresIn;
44  std::chrono::steady_clock::time_point m_nextAuthentication;
45 };
46 #endif
OCS
The OCS class.
Definition: ocs.h:29