summaryrefslogtreecommitdiff
path: root/plugins/CloudFile/src
diff options
context:
space:
mode:
authoraunsane <aunsane@gmail.com>2018-03-09 19:04:44 +0300
committeraunsane <aunsane@gmail.com>2018-03-09 19:05:45 +0300
commit303dd9297732fc943ed3e20ab37587f0c009dfe5 (patch)
tree20957f3c2d2f724dabd3074819a6405c805766fa /plugins/CloudFile/src
parent1f71ad2141a4c7d41f806cc4cbaa25cbf321dd73 (diff)
CloudFile: bugfix
- GDrive: fixed authentication - GDrive: fixed upload for small files - Dropbox: increase "create folder" api method version
Diffstat (limited to 'plugins/CloudFile/src')
-rw-r--r--plugins/CloudFile/src/Services/dropbox_api.h10
-rw-r--r--plugins/CloudFile/src/Services/dropbox_service.cpp2
-rw-r--r--plugins/CloudFile/src/Services/google_api.h25
-rw-r--r--plugins/CloudFile/src/Services/google_service.cpp6
-rw-r--r--plugins/CloudFile/src/Services/microsoft_api.h8
-rw-r--r--plugins/CloudFile/src/Services/microsoft_service.cpp2
-rw-r--r--plugins/CloudFile/src/Services/yandex_api.h5
-rw-r--r--plugins/CloudFile/src/Services/yandex_service.cpp2
-rw-r--r--plugins/CloudFile/src/version.h2
9 files changed, 38 insertions, 24 deletions
diff --git a/plugins/CloudFile/src/Services/dropbox_api.h b/plugins/CloudFile/src/Services/dropbox_api.h
index fefb6ef70d..50e5d44cab 100644
--- a/plugins/CloudFile/src/Services/dropbox_api.h
+++ b/plugins/CloudFile/src/Services/dropbox_api.h
@@ -4,8 +4,8 @@
namespace DropboxAPI
{
#define DROPBOX_API_VER "/2"
-#define DROPBOX_WWW_URL "https://www.dropbox.com"
#define DROPBOX_API "https://api.dropboxapi.com"
+#define DROPBOX_API_OAUTH DROPBOX_API "/oauth2"
#define DROPBOX_API_RPC DROPBOX_API DROPBOX_API_VER
#define DROPBOX_CONTENT "https://content.dropboxapi.com"
#define DROPBOX_API_CU DROPBOX_CONTENT DROPBOX_API_VER
@@ -13,11 +13,13 @@ namespace DropboxAPI
#define DROPBOX_APP_KEY "fa8du7gkf2q8xzg"
#include "../../../miranda-private-keys/Dropbox/secret_key.h"
+#define DROPBOX_API_AUTH "https://www.dropbox.com/oauth2/authorize?response_type=code&client_id=" DROPBOX_APP_KEY
+
class GetAccessTokenRequest : public HttpRequest
{
public:
GetAccessTokenRequest(const char *requestToken) :
- HttpRequest(REQUEST_POST, DROPBOX_API "/oauth2/token")
+ HttpRequest(REQUEST_POST, DROPBOX_API_OAUTH "/token")
{
AddHeader("Content-Type", "application/x-www-form-urlencoded");
@@ -32,7 +34,7 @@ namespace DropboxAPI
{
public:
RevokeAccessTokenRequest(const char *token) :
- HttpRequest(REQUEST_POST, DROPBOX_API "/oauth2/token/revoke")
+ HttpRequest(REQUEST_POST, DROPBOX_API_OAUTH "/token/revoke")
{
AddBearerAuthHeader(token);
}
@@ -150,7 +152,7 @@ namespace DropboxAPI
{
public:
CreateFolderRequest(const char *token, const char *path) :
- HttpRequest(REQUEST_POST, DROPBOX_API_RPC "/files/create_folder")
+ HttpRequest(REQUEST_POST, DROPBOX_API_RPC "/files/create_folder_v2")
{
AddBearerAuthHeader(token);
AddHeader("Content-Type", "application/json");
diff --git a/plugins/CloudFile/src/Services/dropbox_service.cpp b/plugins/CloudFile/src/Services/dropbox_service.cpp
index d5270ef5e8..bec549dc2c 100644
--- a/plugins/CloudFile/src/Services/dropbox_service.cpp
+++ b/plugins/CloudFile/src/Services/dropbox_service.cpp
@@ -40,7 +40,7 @@ bool CDropboxService::IsLoggedIn()
void CDropboxService::Login()
{
- COAuthDlg(this, DROPBOX_WWW_URL "/oauth2/authorize?response_type=code&client_id=" DROPBOX_APP_KEY, RequestAccessTokenThread).DoModal();
+ COAuthDlg(this, DROPBOX_API_AUTH, RequestAccessTokenThread).DoModal();
}
void CDropboxService::Logout()
diff --git a/plugins/CloudFile/src/Services/google_api.h b/plugins/CloudFile/src/Services/google_api.h
index 476a97a0e2..d67ef82012 100644
--- a/plugins/CloudFile/src/Services/google_api.h
+++ b/plugins/CloudFile/src/Services/google_api.h
@@ -4,24 +4,29 @@
namespace GDriveAPI
{
#define GOOGLE_OAUTH "https://accounts.google.com/o/oauth2/v2"
-#define GDRIVE_API "https://www.googleapis.com/drive/v3/files"
-#define GDRIVE_UPLOAD "https://www.googleapis.com/upload/drive/v3/files"
+#define GOOGLE_API "https://www.googleapis.com"
+#define GDRIVE_API_OAUTH GOOGLE_API "/oauth2/v4"
+#define GDRIVE_API_VER "/v3"
+#define GDRIVE_API GOOGLE_API "/drive" GDRIVE_API_VER "/files"
+#define GDRIVE_UPLOAD GOOGLE_API "/upload/drive" GDRIVE_API_VER "/files"
#define GDRIVE_SHARE "https://drive.google.com/open?id=%s"
-#define GOOGLE_APP_ID "528761318515-9hp30q3pcsk7c3qhbajs5ntvi7aiqp0b.apps.googleusercontent.com"
+#define GOOGLE_APP_ID "528761318515-h1etlccvk5vjsbjuuj8i73cud8do4adi.apps.googleusercontent.com"
#include "../../../miranda-private-keys/Google/client_secret.h"
+#define GOOGLE_AUTH GOOGLE_OAUTH "/auth?response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive.file&redirect_uri=https%3A%2F%2Foauth.miranda-ng.org%2Fverification&client_id=" GOOGLE_APP_ID
+
class GetAccessTokenRequest : public HttpRequest
{
public:
GetAccessTokenRequest(const char *code) :
- HttpRequest(REQUEST_POST, "https://www.googleapis.com/oauth2/v4/token")
+ HttpRequest(REQUEST_POST, GDRIVE_API_OAUTH "/token")
{
AddHeader("Content-Type", "application/x-www-form-urlencoded");
- CMStringA data(CMStringDataFormat::FORMAT,
- "redirect_uri=urn:ietf:wg:oauth:2.0:oob&client_id=%s&client_secret=%s&grant_type=authorization_code&code=%s",
- GOOGLE_APP_ID, GOOGLE_CLIENT_SECRET, code);
+ CMStringA data = "redirect_uri=https://oauth.miranda-ng.org/verification";
+ data.AppendFormat("&client_id=%s&client_secret=%s", GOOGLE_APP_ID, GOOGLE_CLIENT_SECRET);
+ data.AppendFormat("&grant_type=authorization_code&code=%s", code);
SetData(data.GetBuffer(), data.GetLength());
}
};
@@ -30,7 +35,7 @@ namespace GDriveAPI
{
public:
RefreshTokenRequest(const char *refreshToken) :
- HttpRequest(REQUEST_POST, "https://www.googleapis.com/oauth2/v4/token")
+ HttpRequest(REQUEST_POST, GDRIVE_API_OAUTH "/token")
{
AddHeader("Content-Type", "application/x-www-form-urlencoded");
@@ -76,8 +81,10 @@ namespace GDriveAPI
body.AppendChar(0x0A);
body.Append("Content-Type: application/octet-stream");
body.AppendChar(0x0A);
+ body.Append("Content-Transfer-Encoding: base64");
+ body.AppendChar(0x0A);
body.AppendChar(0x0A);
- body.Append(data, size);
+ body.Append(ptrA(mir_base64_encode(data, size)));
body.AppendChar(0x0A);
body.Append("--upload--");
diff --git a/plugins/CloudFile/src/Services/google_service.cpp b/plugins/CloudFile/src/Services/google_service.cpp
index dda31097da..0fafdbaf01 100644
--- a/plugins/CloudFile/src/Services/google_service.cpp
+++ b/plugins/CloudFile/src/Services/google_service.cpp
@@ -60,7 +60,7 @@ void CGDriveService::Login()
return;
}
- COAuthDlg dlg(this, GOOGLE_OAUTH "/auth?response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive.file&redirect_uri=urn:ietf:wg:oauth:2.0:oob&client_id=" GOOGLE_APP_ID, RequestAccessTokenThread);
+ COAuthDlg dlg(this, GOOGLE_AUTH, RequestAccessTokenThread);
dlg.DoModal();
}
@@ -84,9 +84,9 @@ unsigned CGDriveService::RequestAccessTokenThread(void *owner, void *param)
NLHR_PTR response(request.Send(service->m_hConnection));
if (response == nullptr || response->resultCode != HTTP_CODE_OK) {
- const char *error = response->dataLength
+ const char *error = response && response->dataLength
? response->pData
- : service->HttpStatusToError(response->resultCode);
+ : service->HttpStatusToError(response ? response->resultCode : 0);
Netlib_Logf(service->m_hConnection, "%s: %s", service->GetAccountName(), error);
//ShowNotification(TranslateT("server does not respond"), MB_ICONERROR);
diff --git a/plugins/CloudFile/src/Services/microsoft_api.h b/plugins/CloudFile/src/Services/microsoft_api.h
index 2545708a45..3dcb34e2ba 100644
--- a/plugins/CloudFile/src/Services/microsoft_api.h
+++ b/plugins/CloudFile/src/Services/microsoft_api.h
@@ -3,17 +3,19 @@
namespace OneDriveAPI
{
-#define MS_OAUTH "https://login.microsoftonline.com/common/oauth2/v2.0"
+#define MICROSOFT_OAUTH "https://login.microsoftonline.com/common/oauth2/v2.0"
#define ONEDRIVE_API "https://graph.microsoft.com/v1.0/drive"
#define MS_APP_ID "72b87ac7-42eb-4a97-a620-91a7f8d8b5ae"
#include "../../../miranda-private-keys/Microsoft/client_secret.h"
+#define MICROSOFT_AUTH MICROSOFT_OAUTH "/authorize?response_type=code&scope=offline_access%20https%3A%2F%2Fgraph.microsoft.com%2Ffiles.readWrite&redirect_uri=https%3A%2F%2Foauth.miranda-ng.org%2Fverification&client_id=" MS_APP_ID
+
class GetAccessTokenRequest : public HttpRequest
{
public:
GetAccessTokenRequest(const char *code) :
- HttpRequest(REQUEST_POST, MS_OAUTH "/token")
+ HttpRequest(REQUEST_POST, MICROSOFT_OAUTH "/token")
{
AddHeader("Content-Type", "application/x-www-form-urlencoded");
@@ -29,7 +31,7 @@ namespace OneDriveAPI
{
public:
RefreshTokenRequest(const char *refreshToken) :
- HttpRequest(REQUEST_POST, MS_OAUTH "/token")
+ HttpRequest(REQUEST_POST, MICROSOFT_OAUTH "/token")
{
AddHeader("Content-Type", "application/x-www-form-urlencoded");
diff --git a/plugins/CloudFile/src/Services/microsoft_service.cpp b/plugins/CloudFile/src/Services/microsoft_service.cpp
index 6f5dfca836..015979191d 100644
--- a/plugins/CloudFile/src/Services/microsoft_service.cpp
+++ b/plugins/CloudFile/src/Services/microsoft_service.cpp
@@ -60,7 +60,7 @@ void COneDriveService::Login()
return;
}
- COAuthDlg dlg(this, MS_OAUTH "/authorize?response_type=code&scope=offline_access%20https%3A%2F%2Fgraph.microsoft.com%2Ffiles.readWrite&redirect_uri=https%3A%2F%2Foauth.miranda-ng.org%2Fverification&client_id=" MS_APP_ID, RequestAccessTokenThread);
+ COAuthDlg dlg(this, MICROSOFT_AUTH, RequestAccessTokenThread);
dlg.DoModal();
}
diff --git a/plugins/CloudFile/src/Services/yandex_api.h b/plugins/CloudFile/src/Services/yandex_api.h
index 56d77feb8c..6c2d97448b 100644
--- a/plugins/CloudFile/src/Services/yandex_api.h
+++ b/plugins/CloudFile/src/Services/yandex_api.h
@@ -4,11 +4,14 @@
namespace YandexAPI
{
#define YANDEX_OAUTH "https://oauth.yandex.ru"
-#define YADISK_API "https://cloud-api.yandex.net/v1/disk/resources"
+#define YADISK_API_VER "/v1"
+#define YADISK_API "https://cloud-api.yandex.net" YADISK_API_VER "/disk/resources"
#define YANDEX_APP_ID "c311a5967cae4efa88d1af97d01ea0e8"
#include "../../../miranda-private-keys/Yandex/client_secret.h"
+#define YANDEX_AUTH YANDEX_OAUTH "/authorize?response_type=code&client_id=" YANDEX_APP_ID
+
class GetAccessTokenRequest : public HttpRequest
{
public:
diff --git a/plugins/CloudFile/src/Services/yandex_service.cpp b/plugins/CloudFile/src/Services/yandex_service.cpp
index 176bcd21a6..0709419cdd 100644
--- a/plugins/CloudFile/src/Services/yandex_service.cpp
+++ b/plugins/CloudFile/src/Services/yandex_service.cpp
@@ -63,7 +63,7 @@ void CYandexService::Login()
return;
}
- COAuthDlg dlg(this, YANDEX_OAUTH "/authorize?response_type=code&client_id=" YANDEX_APP_ID, RequestAccessTokenThread);
+ COAuthDlg dlg(this, YANDEX_AUTH, RequestAccessTokenThread);
dlg.DoModal();
}
diff --git a/plugins/CloudFile/src/version.h b/plugins/CloudFile/src/version.h
index d5cfb30c4b..295a3b73ef 100644
--- a/plugins/CloudFile/src/version.h
+++ b/plugins/CloudFile/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 11
#define __RELEASE_NUM 0
-#define __BUILD_NUM 3
+#define __BUILD_NUM 4
#include <stdver.h>