Aktualizr
C++ SOTA Client
All Classes Namespaces Files Functions Variables Enumerations Enumerator Pages
oauth2.h
1 #ifndef SOTA_CLIENT_TOOLS_OAUTH2_H_
2 #define SOTA_CLIENT_TOOLS_OAUTH2_H_
3 
4 #include <string>
5 #include <utility>
6 
7 enum class AuthenticationResult { kSuccess = 0, kFailure };
8 
9 class OAuth2 {
10  public:
11  /**
12  * Doesn't perform any authentication
13  */
14  OAuth2(std::string server, std::string client_id, std::string client_secret, std::string scope, std::string ca_certs)
15  : server_(std::move(server)),
16  client_id_(std::move(client_id)),
17  client_secret_(std::move(client_secret)),
18  scope_(std::move(scope)),
19  ca_certs_(std::move(ca_certs)) {}
20 
21  /**
22  * Synchronously attempt to get an access token from Auth+
23  */
24  AuthenticationResult Authenticate();
25 
26  std::string token() const { return token_; }
27 
28  private:
29  const std::string server_;
30  const std::string client_id_;
31  const std::string client_secret_;
32  const std::string scope_;
33  const std::string ca_certs_;
34  std::string token_;
35 };
36 
37 // vim: set tabstop=2 shiftwidth=2 expandtab:
38 #endif // SOTA_CLIENT_TOOLS_OAUTH2_H_
OAuth2
Definition: oauth2.h:9
OAuth2::Authenticate
AuthenticationResult Authenticate()
Synchronously attempt to get an access token from Auth+.
Definition: oauth2.cc:25
OAuth2::OAuth2
OAuth2(std::string server, std::string client_id, std::string client_secret, std::string scope, std::string ca_certs)
Doesn't perform any authentication.
Definition: oauth2.h:14