diff options
Diffstat (limited to 'backends/cloud')
-rw-r--r-- | backends/cloud/dropbox/dropboxstorage.cpp | 7 | ||||
-rw-r--r-- | backends/cloud/googledrive/googledrivestorage.cpp | 5 | ||||
-rw-r--r-- | backends/cloud/onedrive/onedrivestorage.cpp | 5 |
3 files changed, 10 insertions, 7 deletions
diff --git a/backends/cloud/dropbox/dropboxstorage.cpp b/backends/cloud/dropbox/dropboxstorage.cpp index b8851b05ec..bcafcf5264 100644 --- a/backends/cloud/dropbox/dropboxstorage.cpp +++ b/backends/cloud/dropbox/dropboxstorage.cpp @@ -36,8 +36,8 @@ namespace Cloud { namespace Dropbox { -char *DropboxStorage::KEY; //can't use ConfMan there yet, loading it on instance creation/auth -char *DropboxStorage::SECRET; //TODO: hide these secrets somehow +char *DropboxStorage::KEY = nullptr; //can't use ConfMan there yet, loading it on instance creation/auth +char *DropboxStorage::SECRET = nullptr; //TODO: hide these secrets somehow void DropboxStorage::loadKeyAndSecret() { Common::String k = ConfMan.get("DROPBOX_KEY", "cloud"); @@ -59,7 +59,8 @@ DropboxStorage::DropboxStorage(Common::String code) { DropboxStorage::~DropboxStorage() {} -void DropboxStorage::getAccessToken(Common::String code) { +void DropboxStorage::getAccessToken(Common::String code) { + if (!KEY || !SECRET) loadKeyAndSecret(); Networking::JsonCallback callback = new Common::Callback<DropboxStorage, Networking::JsonResponse>(this, &DropboxStorage::codeFlowComplete); Networking::CurlJsonRequest *request = new Networking::CurlJsonRequest(callback, nullptr, "https://api.dropboxapi.com/1/oauth2/token"); request->addPostField("code=" + code); diff --git a/backends/cloud/googledrive/googledrivestorage.cpp b/backends/cloud/googledrive/googledrivestorage.cpp index 5eab071599..76ff1dd7fc 100644 --- a/backends/cloud/googledrive/googledrivestorage.cpp +++ b/backends/cloud/googledrive/googledrivestorage.cpp @@ -42,8 +42,8 @@ namespace Cloud { namespace GoogleDrive { -char *GoogleDriveStorage::KEY; //can't use ConfMan there yet, loading it on instance creation/auth -char *GoogleDriveStorage::SECRET; //TODO: hide these secrets somehow +char *GoogleDriveStorage::KEY = nullptr; //can't use ConfMan there yet, loading it on instance creation/auth +char *GoogleDriveStorage::SECRET = nullptr; //TODO: hide these secrets somehow void GoogleDriveStorage::loadKeyAndSecret() { Common::String k = ConfMan.get("GOOGLE_DRIVE_KEY", "cloud"); @@ -67,6 +67,7 @@ GoogleDriveStorage::GoogleDriveStorage(Common::String code) { GoogleDriveStorage::~GoogleDriveStorage() {} void GoogleDriveStorage::getAccessToken(BoolCallback callback, Common::String code) { + if (!KEY || !SECRET) loadKeyAndSecret(); bool codeFlow = (code != ""); if (!codeFlow && _refreshToken == "") { diff --git a/backends/cloud/onedrive/onedrivestorage.cpp b/backends/cloud/onedrive/onedrivestorage.cpp index d1971f904a..6ae5cb0b16 100644 --- a/backends/cloud/onedrive/onedrivestorage.cpp +++ b/backends/cloud/onedrive/onedrivestorage.cpp @@ -38,8 +38,8 @@ namespace Cloud { namespace OneDrive { -char *OneDriveStorage::KEY; //can't use ConfMan there yet, loading it on instance creation/auth -char *OneDriveStorage::SECRET; //TODO: hide these secrets somehow +char *OneDriveStorage::KEY = nullptr; //can't use ConfMan there yet, loading it on instance creation/auth +char *OneDriveStorage::SECRET = nullptr; //TODO: hide these secrets somehow void OneDriveStorage::loadKeyAndSecret() { Common::String k = ConfMan.get("ONEDRIVE_KEY", "cloud"); @@ -63,6 +63,7 @@ OneDriveStorage::OneDriveStorage(Common::String code) { OneDriveStorage::~OneDriveStorage() {} void OneDriveStorage::getAccessToken(BoolCallback callback, Common::String code) { + if (!KEY || !SECRET) loadKeyAndSecret(); bool codeFlow = (code != ""); if (!codeFlow && _refreshToken == "") { |